REST API and static pages (best solution)

I am relatively new to API development. I often face different problems and have many questions. The main question is "How to implement something according to best practices and patterns."
My goal is not only to write an API and forget about it, but also to maintain and make it easier for others to use.

Now I have a question about static pages and an answer JSON

On my site I have a number of static pages ( About Us, Contact Us, Shipping, Payment......

), so pages with static context are essentially html and images.

So I need these pages in my application (in this case Android Standalone App) to be part of the application, but they don't have to be hardcoded, but they will be loaded from the site using the API to update them.

I have several questions:

  • What the url should look like if it's some amount of persistent url (,

    ...). Or should it look like


  • What the structure of the response should look like JSON

    . The problem here is that the content of static pages is completely different, for example, the Contact Us

    page will have such important information: phone numbers, emails, and maybe independent properties in the response JSON

    . About Us

    the page has another main part. And there can be many such pages. How to keep it unified?

  • It might be better to unify JSON responses to server properties only (short description, full text, image ...) and send raw text or even html and work with the client. But it doesn't seem like a good idea.

Perhaps there is another correct way to implement this. Or it won't be part of the API at all, and it should be done differently.

I would be grateful to everyone, thanks for the help in advance.


source to share

1 answer

I recommend following the REST API project. In your case, you only have static pages. This means you can have urls:

GET    /api/pages/{id}
POST   /api/pages
PUT    /api/pages/{id}


Yours {id}

can be a primary key (int), guid

or a unique string. In case of static web pages, I usually recommend using SeoUrl ( about-us

, contact-us


When your data structure is a variable, you can create key-value pairs or a list of objects. It might look like this:

   "name":"About Us",
   "text":"Some HTML text",


Of course, there are more ways, and the final decision is definitely up to you. Try to find articles related to "restful api design".



All Articles