{"id":3824,"date":"2018-07-05T17:07:46","date_gmt":"2018-07-05T11:37:46","guid":{"rendered":"https:\/\/code4developers.com\/?p=3824"},"modified":"2018-07-06T15:46:10","modified_gmt":"2018-07-06T10:16:10","slug":"restful-api-best-practices","status":"publish","type":"post","link":"https:\/\/code4developers.com\/restful-api-best-practices\/","title":{"rendered":"RESTful API best practices and Designing guidelines\u200a"},"content":{"rendered":"<p id=\"1c92\" class=\"graf graf--p graf-after--h3\">Facebook, Google, Github, Netflix and few other tech giants have given a chance to the developers and products to consume their data through APIs, and became a platform for them. Even if you are not writing RESTful API for other developers and products, it is always very healthy for your application to have beautifully crafted APIs.<!--more--><\/p>\n<p>The API is an interface, through which many developers interact with the data. A good designed API is always very easy to use and makes the developer\u2019s life very smooth. API is the GUI for developers, if it is confusing or not verbose, then the developer will start finding the alternatives or stop using it. Developers\u2019 experience is the most important metric to measure the quality of the APIs.<\/p>\n<p id=\"2a2e\" class=\"graf graf--p graf-after--p\">There is a long debate going on the internet, about the best ways to design the APIs, and is one of the most nuanced. There are no official guidelines defined for the same.<\/p>\n<section class=\"section section--body section--first\">\n<div class=\"section-content\">\n<div class=\"section-inner sectionLayout--insetColumn\">\n<h3 id=\"8dbe\" class=\"graf graf--h3 graf-after--figure\"><span id=\"1-terminologies\"><strong class=\"markup--strong markup--h3-strong\">1) Terminologies<\/strong><\/span><\/h3>\n<p id=\"e9fb\" class=\"graf graf--p graf-after--h3\">The following are the most important terms related to REST APIs<\/p>\n<ul class=\"postList\">\n<li id=\"845d\" class=\"graf graf--li graf-after--p\"><strong class=\"markup--strong markup--li-strong\">Resource<\/strong> is an object or representation of something, which has some associated data with it and there can be set of methods to operate on it. E.g. Animals, schools and employees are resources and <em class=\"markup--em markup--li-em\">delete, add, update <\/em>are the operations to be performed on these resources.<\/li>\n<li id=\"2b6e\" class=\"graf graf--li graf-after--li\"><strong class=\"markup--strong markup--li-strong\">Collections<\/strong> are set of resources, e.g <em class=\"markup--em markup--li-em\">Companies<\/em> is the collection of <em class=\"markup--em markup--li-em\">Company<\/em> resource.<\/li>\n<li id=\"d49d\" class=\"graf graf--li graf-after--li\"><strong class=\"markup--strong markup--li-strong\">URL<\/strong> (Uniform <strong class=\"markup--strong markup--li-strong\">Resource<\/strong> Locator) is a path through which a <strong class=\"markup--strong markup--li-strong\">resource <\/strong>can be located and some actions can be performed on it.<\/li>\n<\/ul>\n<h3 id=\"0a92\" class=\"graf graf--h3 graf-after--li\"><span id=\"2-api-endpoint\">2) API\u00a0endpoint<\/span><\/h3>\n<p id=\"b7c1\" class=\"graf graf--p graf-after--h3\">Let\u2019s write few APIs for <strong class=\"markup--strong markup--p-strong\">Companies<\/strong> which has some <strong class=\"markup--strong markup--p-strong\">Employees,<\/strong> to understand more.<br \/>\n<code class=\"markup--code markup--p-code\">\/getAllEmployees<\/code> is an API which will respond with the list of employees. Few more APIs around a <strong class=\"markup--strong markup--p-strong\">Company<\/strong> will look like as follows:<\/p>\n<ul class=\"postList\">\n<li id=\"89f1\" class=\"graf graf--li graf-after--p\"><code class=\"markup--code markup--li-code\"><em class=\"markup--em markup--li-em\">\/addNewEmployee<\/em><\/code><\/li>\n<li id=\"c211\" class=\"graf graf--li graf-after--li\"><code class=\"markup--code markup--li-code\"><em class=\"markup--em markup--li-em\">\/updateEmployee<\/em><\/code><\/li>\n<li id=\"066f\" class=\"graf graf--li graf-after--li\"><code class=\"markup--code markup--li-code\"><em class=\"markup--em markup--li-em\">\/deleteEmployee<\/em><\/code><\/li>\n<li id=\"0f1b\" class=\"graf graf--li graf-after--li\"><code class=\"markup--code markup--li-code\"><em class=\"markup--em markup--li-em\">\/deleteAllEmployees<\/em><\/code><\/li>\n<li id=\"adf6\" class=\"graf graf--li graf-after--li\"><code class=\"markup--code markup--li-code\"><em class=\"markup--em markup--li-em\">\/promoteEmployee<\/em><\/code><\/li>\n<li id=\"2ba1\" class=\"graf graf--li graf-after--li\"><code class=\"markup--code markup--li-code\"><em class=\"markup--em markup--li-em\">\/promoteAllEmployees<\/em><\/code><\/li>\n<\/ul>\n<p id=\"66da\" class=\"graf graf--p graf-after--li\">And there will be tons of other API endpoints like these for different operations. All of those will contain many redundant actions. Hence, all these API endpoints would be burdensome to maintain, when API count increases.<\/p>\n<p id=\"1570\" class=\"graf graf--p graf-after--p\"><strong class=\"markup--strong markup--p-strong\">What is wrong?<br \/>\n<\/strong>The URL should only contain resources(nouns) not actions or verbs. The API path<code class=\"markup--code markup--p-code\">\/addNewEmployee<\/code> contains the action <code class=\"markup--code markup--p-code\">addNew<\/code> along with the resource name <code class=\"markup--code markup--p-code\">Employee<\/code>.<\/p>\n<p id=\"d7cf\" class=\"graf graf--p graf-after--p\"><strong class=\"markup--strong markup--p-strong\">Then what is the correct way?<br \/>\n<\/strong><code class=\"markup--code markup--p-code\">\/companies<\/code> endpoint is a good example, which contains no action. But the question is how do we tell the server about the actions to be performed on <code class=\"markup--code markup--p-code\">companies<\/code> resource viz. whether to add, delete or update?<\/p>\n<p id=\"6401\" class=\"graf graf--p graf-after--p\">This is where the <a class=\"markup--anchor markup--p-anchor\" href=\"https:\/\/en.wikipedia.org\/wiki\/Hypertext_Transfer_Protocol#Request_methods\" target=\"_blank\" rel=\"noopener\" data-href=\"https:\/\/en.wikipedia.org\/wiki\/Hypertext_Transfer_Protocol#Request_methods\" data->HTTP methods<\/a> (GET, POST, DELETE, PUT), also called as verbs, play the role.<\/p>\n<p id=\"4204\" class=\"graf graf--p graf-after--p\">The resource should always be <strong class=\"markup--strong markup--p-strong\">plural<\/strong> in the API endpoint and if we want to access one instance of the resource, we can always pass the id\u00a0in\u00a0the URL.<\/p>\n<ul class=\"postList\">\n<li id=\"bd3b\" class=\"graf graf--li graf-after--p\">method <code class=\"markup--code markup--li-code\">GET<\/code> path <code class=\"markup--code markup--li-code\">\/companies<\/code> should get the list of all companies<\/li>\n<li id=\"b1e9\" class=\"graf graf--li graf-after--li\">method <code class=\"markup--code markup--li-code\">GET<\/code> path <code class=\"markup--code markup--li-code\">\/companies\/34<\/code> should get the detail of company 34<\/li>\n<li id=\"c5c5\" class=\"graf graf--li graf-after--li\">method <code class=\"markup--code markup--li-code\">DELETE<\/code> path <code class=\"markup--code markup--li-code\">\/companies\/34<\/code> should delete company 34<\/li>\n<\/ul>\n<p id=\"6786\" class=\"graf graf--p graf-after--li\">In few other use cases, if we have resources under a resource, e.g Employees of a Company, then few of the sample API endpoints would be:<\/p>\n<ul class=\"postList\">\n<li id=\"e2fa\" class=\"graf graf--li graf-after--p\"><code class=\"markup--code markup--li-code\">GET \/companies\/3\/employees<\/code> should get the list of all employees from company 3<\/li>\n<li id=\"d25a\" class=\"graf graf--li graf-after--li\"><code class=\"markup--code markup--li-code\">GET \/companies\/3\/employees\/45<\/code> should get the details of employee 45, which belongs to company 3<\/li>\n<li id=\"d140\" class=\"graf graf--li graf-after--li\"><code class=\"markup--code markup--li-code\">DELETE \/companies\/3\/employees\/45<\/code> should delete employee 45, which belongs to company 3<\/li>\n<li id=\"bf31\" class=\"graf graf--li graf-after--li\"><code class=\"markup--code markup--li-code\">POST \/companies<\/code> should create a new company and return the details of the new company created<\/li>\n<\/ul>\n<p id=\"0163\" class=\"graf graf--p graf-after--li\">Isn\u2019t the APIs are now more precise and consistent? \ud83d\ude0e<\/p>\n<p id=\"1dfb\" class=\"graf graf--p graf-after--p\"><strong class=\"markup--strong markup--p-strong\"><em class=\"markup--em markup--p-em\">Conclusion: <\/em><\/strong><em class=\"markup--em markup--p-em\">The paths should contain the plural form of resources and the HTTP method should define the kind of action to be performed on the resource.<\/em><\/p>\n<h3 id=\"6548\" class=\"graf graf--h3 graf-after--p\"><span id=\"3-http-methods-verbs\">3) HTTP methods\u00a0(verbs)<\/span><\/h3>\n<p id=\"040e\" class=\"graf graf--p graf-after--h3\">HTTP has defined few sets of methods which indicates the type of action to be performed on the resources.<\/p>\n<blockquote id=\"165f\" class=\"graf graf--pullquote graf-after--p\"><p><strong><em><span class=\"markup--quote markup--pullquote-quote is-other\" data-creator-ids=\"anon\">The URL is a sentence, where resources are nouns and HTTP methods are\u00a0verbs.<\/span><\/em><\/strong><\/p><\/blockquote>\n<p id=\"5e54\" class=\"graf graf--p graf-after--pullquote\">The important HTTP methods are as follows:<\/p>\n<ol class=\"postList\">\n<li id=\"9d4c\" class=\"graf graf--li graf-after--p\"><code class=\"markup--code markup--li-code\">GET<\/code> method requests data from the resource and should not produce any side effect.<br \/>\nE.g <code class=\"markup--code markup--li-code\">\/companies\/3\/employees<\/code> returns list of all employees from company 3.<\/li>\n<li id=\"a8f9\" class=\"graf graf--li graf-after--li\"><code class=\"markup--code markup--li-code\">POST<\/code> method requests the server to <strong class=\"markup--strong markup--li-strong\">create<\/strong> a resource in the database, mostly when a web form is submitted.<br \/>\nE.g <code class=\"markup--code markup--li-code\">\/companies\/3\/employees<\/code> creates a new Employee of company 3.<br \/>\n<code class=\"markup--code markup--li-code\">POST<\/code> is non-<a class=\"markup--anchor markup--li-anchor\" href=\"https:\/\/en.wikipedia.org\/wiki\/Idempotence#Computer_science_meaning\" target=\"_blank\" rel=\"noopener\" data-href=\"https:\/\/en.wikipedia.org\/wiki\/Idempotence#Computer_science_meaning\" data->idempotent<\/a> which means multiple requests will have different effects.<\/li>\n<li id=\"010c\" class=\"graf graf--li graf-after--li\"><code class=\"markup--code markup--li-code\">PUT<\/code> method requests the server to <strong class=\"markup--strong markup--li-strong\">update<\/strong> resource or <strong class=\"markup--strong markup--li-strong\">create<\/strong> the resource, if it doesn\u2019t exist.<br \/>\nE.g. <code class=\"markup--code markup--li-code\">\/companies\/3\/employees\/john<\/code> will request the server to update, or create if doesn\u2019t exist, the <em class=\"markup--em markup--li-em\">john<\/em> resource in employees collection under company 3.<br \/>\n<code class=\"markup--code markup--li-code\">PUT<\/code> is <a class=\"markup--anchor markup--li-anchor\" href=\"https:\/\/en.wikipedia.org\/wiki\/Idempotence#Computer_science_meaning\" target=\"_blank\" rel=\"noopener\" data-href=\"https:\/\/en.wikipedia.org\/wiki\/Idempotence#Computer_science_meaning\" data->idempotent<\/a> which means multiple requests will have the same effects.<\/li>\n<li id=\"0af7\" class=\"graf graf--li graf-after--li\"><code class=\"markup--code markup--li-code\">DELETE<\/code> method requests that the resources, or its instance, should be removed from the database.<br \/>\nE.g <code class=\"markup--code markup--li-code\">\/companies\/3\/employees\/john\/<\/code> will request the server to delete <em class=\"markup--em markup--li-em\">john <\/em>resource from the employees collection under the company 3.<\/li>\n<\/ol>\n<p id=\"bb8f\" class=\"graf graf--p graf-after--li\">There are <a class=\"markup--anchor markup--p-anchor\" href=\"https:\/\/en.wikipedia.org\/wiki\/Hypertext_Transfer_Protocol#Request_methods\" target=\"_blank\" rel=\"noopener\" data-href=\"https:\/\/en.wikipedia.org\/wiki\/Hypertext_Transfer_Protocol#Request_methods\" data->few other methods<\/a> which we will discuss in another post.<\/p>\n<h3 id=\"4b9d\" class=\"graf graf--h3 graf-after--p\"><span id=\"4-http-response-status-codes\">4) HTTP response status\u00a0codes<\/span><\/h3>\n<p id=\"ffdb\" class=\"graf graf--p graf-after--h3\">When the client raises a request to the server through an API, the client should know the feedback, whether it failed, passed or the request was wrong. HTTP status codes are bunch of standardized codes which has various explanations in various scenarios. The server should always return the right status code.<br \/>\nThe following are the important categorization of HTTP codes:<\/p>\n<h4 id=\"6b04\" class=\"graf graf--h4 graf-after--p\"><span id=\"2xx-success-category\"><strong class=\"markup--strong markup--h4-strong\">2xx (Success category)<\/strong><\/span><\/h4>\n<p id=\"e469\" class=\"graf graf--p graf-after--h4\">These status codes represent that the requested action was received and successfully processed by the server.<\/p>\n<ul class=\"postList\">\n<li id=\"3235\" class=\"graf graf--li graf-after--p\"><strong class=\"markup--strong markup--li-strong\">200 Ok <\/strong>The standard HTTP response representing success for GET, PUT or POST.<\/li>\n<li id=\"af87\" class=\"graf graf--li graf-after--li\"><strong class=\"markup--strong markup--li-strong\">201 Created <\/strong>This status code should be returned whenever the new instance is created. E.g on creating a new instance, using POST method, should always return 201 status code.<\/li>\n<li id=\"8e2e\" class=\"graf graf--li graf-after--li\"><strong class=\"markup--strong markup--li-strong\">204 No Content <\/strong>represents the request is successfully processed, but has not returned any content.<br \/>\nDELETE can be a good example of this.<br \/>\nThe API <code class=\"markup--code markup--li-code\">DELETE \/companies\/43\/employees\/2<\/code> will delete the employee 2 and in return we do not need any data in the response body of the API, as we explicitly asked the system to delete. If there is any error, like if <code class=\"markup--code markup--li-code\">employee 2<\/code> does not exist in the database, then the response code would be not be of <code class=\"markup--code markup--li-code\">2xx Success Category<\/code> but around <code class=\"markup--code markup--li-code\">4xx Client Error category<\/code>.<\/li>\n<\/ul>\n<h4 id=\"d361\" class=\"graf graf--h4 graf-after--li\"><span id=\"3xx-redirection-category\"><strong class=\"markup--strong markup--h4-strong\">3xx (Redirection Category)<\/strong><\/span><\/h4>\n<ul class=\"postList\">\n<li id=\"3a8c\" class=\"graf graf--li graf-after--h4\"><strong class=\"markup--strong markup--li-strong\">304 Not Modified<\/strong> indicates that the client has the response already in its cache. And hence there is no need to transfer the same data again.<\/li>\n<\/ul>\n<h4 id=\"b308\" class=\"graf graf--h4 graf-after--li\"><span id=\"4xx-client-error-category\">4xx (Client Error Category)<\/span><\/h4>\n<p id=\"6773\" class=\"graf graf--p graf-after--h4\">These status codes represent that the client has raised a faulty request.<\/p>\n<ul class=\"postList\">\n<li id=\"8daf\" class=\"graf graf--li graf-after--p\"><strong class=\"markup--strong markup--li-strong\">400 Bad Request<\/strong> indicates that the request by the client was not processed, as the server could not understand what the client is asking for.<\/li>\n<li id=\"85c5\" class=\"graf graf--li graf-after--li\"><strong class=\"markup--strong markup--li-strong\">401 Unauthorized<\/strong> indicates that the client is not allowed to access resources, and should re-request with the required credentials.<\/li>\n<li id=\"d2b1\" class=\"graf graf--li graf-after--li\"><strong class=\"markup--strong markup--li-strong\">403 Forbidden <\/strong>indicates that the request is valid and the client is authenticated, but the client is not allowed access the page or resource for any reason. E.g sometimes the authorized client is not allowed to access the directory on the server.<\/li>\n<li id=\"c9e3\" class=\"graf graf--li graf-after--li\"><strong class=\"markup--strong markup--li-strong\">404 Not Found <\/strong>indicates that the requested resource is not available now.<\/li>\n<li id=\"b4b5\" class=\"graf graf--li graf-after--li\"><strong class=\"markup--strong markup--li-strong\">410 Gone <\/strong>indicates that the requested resource is no longer available which has been intentionally moved.<\/li>\n<\/ul>\n<h4 id=\"a203\" class=\"graf graf--h4 graf-after--li\"><span id=\"5xx-server-error-category\">5xx (Server Error Category)<\/span><\/h4>\n<ul class=\"postList\">\n<li id=\"f074\" class=\"graf graf--li graf-after--h4\"><strong class=\"markup--strong markup--li-strong\">500 Internal Server Error<\/strong> indicates that the request is valid, but the server is totally confused and the server is asked to serve some unexpected condition.<\/li>\n<li id=\"b04e\" class=\"graf graf--li graf-after--li\"><strong class=\"markup--strong markup--li-strong\">503 Service Unavailable <\/strong>indicates that the server is down or unavailable to receive and process the request. Mostly if the server is undergoing maintenance.<\/li>\n<\/ul>\n<h3 id=\"c568\" class=\"graf graf--h3 graf-after--li\"><span id=\"5-field-name-casing-convention\">5) Field name casing convention<\/span><\/h3>\n<p id=\"10b6\" class=\"graf graf--p graf-after--h3\">You can follow any casing convention, but make sure it is consistent across the application. If the request body or response type is <a class=\"markup--anchor markup--p-anchor\" href=\"https:\/\/en.wikipedia.org\/wiki\/JSON\" target=\"_blank\" rel=\"noopener\" data-href=\"https:\/\/en.wikipedia.org\/wiki\/JSON\" data->JSON<\/a> then please follow camelCase to maintain the consistency.<\/p>\n<h3 id=\"4b14\" class=\"graf graf--h3 graf-after--p\"><span id=\"6-searching-sorting-filtering-and-pagination\">6) Searching, sorting, filtering and pagination<\/span><\/h3>\n<p id=\"189b\" class=\"graf graf--p graf-after--h3\">All of these actions are simply the query on one dataset. There will be no new set of APIs to handle these actions. We need to append the query params with the GET method API.<br \/>\nLet\u2019s understand with few examples how to implement these actions.<\/p>\n<ul class=\"postList\">\n<li id=\"6c8b\" class=\"graf graf--li graf-after--p\"><strong class=\"markup--strong markup--li-strong\">Sorting <\/strong>In case, the client wants to get the sorted list of companies, the <code class=\"markup--code markup--li-code\">GET \/companies<\/code> endpoint should accept multiple sort params in the query.<br \/>\nE.g <code class=\"markup--code markup--li-code\">GET \/companies?sort=rank_asc<\/code> would sort the companies by its rank in ascending order.<\/li>\n<li id=\"853b\" class=\"graf graf--li graf-after--li\"><strong class=\"markup--strong markup--li-strong\">Filtering <\/strong>For filtering the dataset, we can pass various options through query params.<br \/>\nE.g <code class=\"markup--code markup--li-code\">GET \/companies?category=banking&amp;location=india<\/code> would filter the companies list data with the company category of Banking and where the location is India.<\/li>\n<li id=\"c40c\" class=\"graf graf--li graf-after--li\"><strong class=\"markup--strong markup--li-strong\">Searching <\/strong>When searching the company name in companies list the API endpoint should be <code class=\"markup--code markup--li-code\">GET \/companies?search=Digital Mckinsey<\/code><\/li>\n<li id=\"5db6\" class=\"graf graf--li graf-after--li\"><strong class=\"markup--strong markup--li-strong\">Pagination <\/strong>When the dataset is too large, we divide the data set into smaller chunks, which helps in improving the performance and is easier to handle the response. Eg. <code class=\"markup--code markup--li-code\">GET \/companies?page=23<\/code> means get the list of companies on 23rd page.<\/li>\n<\/ul>\n<p id=\"25f5\" class=\"graf graf--p graf-after--li\">If adding many query params in GET methods makes the URI too long, the server may respond with <code class=\"markup--code markup--p-code\">414 URI Too long<\/code> HTTP status, in those cases params can also be passed in the request body of the <code class=\"markup--code markup--p-code\">POST<\/code> method.<\/p>\n<h3 id=\"4ad0\" class=\"graf graf--h3 graf-after--p\"><span id=\"7-versioning\">7) Versioning<\/span><\/h3>\n<p id=\"c23f\" class=\"graf graf--p graf-after--h3\">When your APIs are being consumed by the world, upgrading the APIs with some breaking change would also lead to breaking the existing products or services using your APIs.<\/p>\n<p id=\"b173\" class=\"graf graf--p graf-after--p graf--trailing\"><code class=\"markup--code markup--p-code\">http:\/\/api.yourservice.com\/v1\/companies\/34\/employees<\/code> is a good example, which has the version number of the API in the path. If there is any major breaking update, we can name the new set of APIs as <code class=\"markup--code markup--p-code\">v2<\/code> or <code class=\"markup--code markup--p-code\">v1.x.x<\/code><\/p>\n<\/div>\n<\/div>\n<\/section>\n<section class=\"section section--body section--last\">\n<h3 id=\"conslusion\">Conslusion<\/h3>\n<div class=\"section-divider\">These guidelines are compiled on my experience of development. I would love to know your views on the pointers mentioned above. Please leave a comment, and let me know!<\/div>\n<div class=\"section-content\">\n<div class=\"section-inner sectionLayout--insetColumn\">\n<p id=\"5bcf\" class=\"graf graf--p graf-after--p\">If you liked this post, please share, comment and give few feedback<\/p>\n<p>credits : <a class=\"ds-link ds-link--styleSubtle link link--darken link--accent u-accentColor--textNormal u-accentColor--textDarken\" dir=\"auto\" href=\"https:\/\/hackernoon.com\/@haldar.mahesh?source=user_profile---------0---------------------\" data-action=\"show-user-card\" data-action-source=\"user_profile---------0---------------------\" data-action-value=\"665febc2fd53\" data-action-type=\"hover\" data-user-id=\"665febc2fd53\" data-collection-slug=\"hacker-daily\" target=\"_blank\" rel=\"noopener\">Mahesh Haldar<\/a><\/p>\n<\/div>\n<\/div>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<p>Facebook, Google, Github, Netflix and few other tech giants have given a chance to the developers and products to consume their data through APIs, and became a platform for them.&hellip;<\/p>\n","protected":false},"author":7,"featured_media":3826,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[222],"tags":[211,218,220,216,212,213,217,219,208,209,210,214,215,221],"powerkit_post_featured":[],"class_list":{"0":"post-3824","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-web-services","8":"tag-api-endpoint","9":"tag-casing-convention","10":"tag-collections","11":"tag-filtering","12":"tag-http-methods","13":"tag-http-response-status-codes","14":"tag-pagination","15":"tag-resource","16":"tag-restful-api","17":"tag-restful-api-best-practices","18":"tag-restful-api-designing-guidelines","19":"tag-searching","20":"tag-sorting","21":"tag-url"},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/code4developers.com\/wp-content\/uploads\/2018\/07\/rest_api.png?fit=406%2C430&ssl=1","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8NAi4-ZG","jetpack-related-posts":[{"id":3158,"url":"https:\/\/code4developers.com\/intro-to-express\/","url_meta":{"origin":3824,"position":0},"title":"Intro to Express.","author":"Arif Khoja","date":"December 8, 2017","format":false,"excerpt":"This is a super short, and super simple introduction to both Express and RESTful services. There will be details about both I won\u2019t touch on. It is only intended as a starting point, and I recommend taking a deep dive into each topic on their own. RESTful web services are\u2026","rel":"","context":"In &quot;NodeJS&quot;","block_context":{"text":"NodeJS","link":"https:\/\/code4developers.com\/category\/nodejs\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/code4developers.com\/wp-content\/uploads\/2017\/12\/expressjs.jpg?fit=225%2C225&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":5161,"url":"https:\/\/code4developers.com\/getting-started-with-google-maps-places-api\/","url_meta":{"origin":3824,"position":1},"title":"Getting started with Google Maps Places API","author":"Arif Khoja","date":"October 17, 2019","format":false,"excerpt":"If you want to get all of the restaurant data from a specific city by text search in your application, you have come to the right place. In this tutorial, you\u2019re going to learn how to do exactly that using Google Maps Places API. Also, I will be covering how\u2026","rel":"","context":"In &quot;Cloud&quot;","block_context":{"text":"Cloud","link":"https:\/\/code4developers.com\/category\/cloud\/"},"img":{"alt_text":"places-api","src":"https:\/\/i0.wp.com\/code4developers.com\/wp-content\/uploads\/2019\/10\/places-api.png?fit=1026%2C1200&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/code4developers.com\/wp-content\/uploads\/2019\/10\/places-api.png?fit=1026%2C1200&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/code4developers.com\/wp-content\/uploads\/2019\/10\/places-api.png?fit=1026%2C1200&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/code4developers.com\/wp-content\/uploads\/2019\/10\/places-api.png?fit=1026%2C1200&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":6553,"url":"https:\/\/code4developers.com\/cors-error-and-its-solutions\/","url_meta":{"origin":3824,"position":2},"title":"CORS Error And Its Solutions","author":"Arif Khoja","date":"March 15, 2020","format":false,"excerpt":"By the end of this short tutorial, you\u2019ll have a better understanding of: Why CORS error is occurring? What is CORS? and, Find a few ways to fix CORS error: Enable CORS Make an HTTP Request from a Server Use Proxy Server Let\u2019s say, you will need to make an\u2026","rel":"","context":"In &quot;JavaScript&quot;","block_context":{"text":"JavaScript","link":"https:\/\/code4developers.com\/category\/javascript\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/code4developers.com\/wp-content\/uploads\/2018\/04\/cors-1.png?fit=375%2C210&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":3296,"url":"https:\/\/code4developers.com\/whats-new-in-android-p-developer-preview\/","url_meta":{"origin":3824,"position":3},"title":"What\u2019s new in Android P developer preview?","author":"Arif Khoja","date":"March 9, 2018","format":false,"excerpt":"As it has for the last couple years, Google is releasing a developer preview of the next version of Android in March. Before you ask, no, we don\u2019t know the name beyond \u201cAndroid P.\u201d Another thing we don\u2019t know is just how big the user-facing changes will be this time\u2026","rel":"","context":"In &quot;Andriod&quot;","block_context":{"text":"Andriod","link":"https:\/\/code4developers.com\/category\/andriod\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/code4developers.com\/wp-content\/uploads\/2018\/03\/Android.jpg?fit=1200%2C1200&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/code4developers.com\/wp-content\/uploads\/2018\/03\/Android.jpg?fit=1200%2C1200&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/code4developers.com\/wp-content\/uploads\/2018\/03\/Android.jpg?fit=1200%2C1200&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/code4developers.com\/wp-content\/uploads\/2018\/03\/Android.jpg?fit=1200%2C1200&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/code4developers.com\/wp-content\/uploads\/2018\/03\/Android.jpg?fit=1200%2C1200&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":3216,"url":"https:\/\/code4developers.com\/superstruct\/","url_meta":{"origin":3824,"position":4},"title":"Superstruct","author":"Arif Khoja","date":"January 31, 2018","format":false,"excerpt":"I stumbled upon this GitHub project a few days ago. It\u2019s called Superstruct, and it looks like an awesome way to validate data in JavaScript. Let me explain. You probably want to make sure that you get the kind of data you expect as input in JavaScript, either from your\u2026","rel":"","context":"In &quot;JavaScript&quot;","block_context":{"text":"JavaScript","link":"https:\/\/code4developers.com\/category\/javascript\/"},"img":{"alt_text":"javascript","src":"https:\/\/i0.wp.com\/code4developers.com\/wp-content\/uploads\/2017\/10\/javascript.jpg?fit=750%2C422&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/code4developers.com\/wp-content\/uploads\/2017\/10\/javascript.jpg?fit=750%2C422&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/code4developers.com\/wp-content\/uploads\/2017\/10\/javascript.jpg?fit=750%2C422&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/code4developers.com\/wp-content\/uploads\/2017\/10\/javascript.jpg?fit=750%2C422&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":3510,"url":"https:\/\/code4developers.com\/cors-anywhere\/","url_meta":{"origin":3824,"position":5},"title":"CORS Anywhere","author":"Arif Khoja","date":"May 3, 2018","format":false,"excerpt":"After a recent domain change at my workplace one of the API endpoints became inaccessible due to some configuration problems resulting in incorrect behavior in regards to cross-origin resource sharing policy. It interfered with one non-critical function of the website and was a bit of a nuisances but not big\u2026","rel":"","context":"In &quot;JavaScript&quot;","block_context":{"text":"JavaScript","link":"https:\/\/code4developers.com\/category\/javascript\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/code4developers.com\/wp-content\/uploads\/2018\/04\/cors-1.png?fit=375%2C210&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/code4developers.com\/wp-json\/wp\/v2\/posts\/3824","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/code4developers.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/code4developers.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/code4developers.com\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/code4developers.com\/wp-json\/wp\/v2\/comments?post=3824"}],"version-history":[{"count":5,"href":"https:\/\/code4developers.com\/wp-json\/wp\/v2\/posts\/3824\/revisions"}],"predecessor-version":[{"id":3832,"href":"https:\/\/code4developers.com\/wp-json\/wp\/v2\/posts\/3824\/revisions\/3832"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/code4developers.com\/wp-json\/wp\/v2\/media\/3826"}],"wp:attachment":[{"href":"https:\/\/code4developers.com\/wp-json\/wp\/v2\/media?parent=3824"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/code4developers.com\/wp-json\/wp\/v2\/categories?post=3824"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/code4developers.com\/wp-json\/wp\/v2\/tags?post=3824"},{"taxonomy":"powerkit_post_featured","embeddable":true,"href":"https:\/\/code4developers.com\/wp-json\/wp\/v2\/powerkit_post_featured?post=3824"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}