{"id":650,"date":"2022-10-31T11:18:25","date_gmt":"2022-10-31T11:18:25","guid":{"rendered":"https:\/\/infobip.com\/developers\/?p=650"},"modified":"2023-09-11T14:33:41","modified_gmt":"2023-09-11T14:33:41","slug":"good-uri-practices-nouns-and-verbs-id-types-and-requesting-data-formats","status":"publish","type":"post","link":"https:\/\/www.infobip.com\/developers\/blog\/good-uri-practices-nouns-and-verbs-id-types-and-requesting-data-formats","title":{"rendered":"Good URI Practices: nouns and verbs, ID types, and requesting data formats\u00a0"},"content":{"rendered":"\n<p><strong>Modeling Actions: Nouns vs Verbs AKA \u201cHow to model actions\u201d<\/strong>&nbsp;<\/p>\n\n\n\n<p>The URI Structure of an API should be as meaningful and predictable as possible. The idea is to have something that the user can understand.&nbsp;<\/p>\n\n\n\n<p>An API is resource-centric: it deals with resources and with operations on those resources.&nbsp;<\/p>\n\n\n\n<p>Operations (verbs) should be represented via HTTP verbs on resources. This way we work with the HTTP protocol and its semantics.&nbsp;<\/p>\n\n\n\n<p>A verb in the URI is \u2013 always, always, always \u2013 a design smell.&nbsp;<\/p>\n\n\n\n<p class=\"has-vivid-red-color has-text-color\">\ud83d\udc4e <strong>BAD:<\/strong> \u2026\/account\/<strong>pay<\/strong>&nbsp;<\/p>\n\n\n\n<p>When it comes down to a single verb, the URI semantic means that there is only 1 operation available to do in this URI, which is to \u201cpay\u201d. Since it is a verb, it also means that it is not the actual resource of the API. There is not a table in our database named \u201cpay\u201d. So, this entire URI is render useless for anything else than \u201cpay\u201d&nbsp;<\/p>\n\n\n\n<p class=\"has-vivid-green-cyan-color has-text-color\">\ud83d\udc4d <strong>BETTER:<\/strong> \u2026\/account\/<strong>payment<\/strong>&nbsp;<\/p>\n\n\n\n<p>When using a noun, it makes a representation of a relation in the URI. It means we can work with the resource instead of the action. We can set more than just 1 operation like the verb in this UIR, which is a better approach and makes more sense to the user. All operations related to this entity, can be done in a noun URI.&nbsp;<\/p>\n\n\n\n<p class=\"has-vivid-green-cyan-color has-text-color\">\ud83d\udc4d\ud83d\udc4d <strong>EVEN BETTER<\/strong>: \u2026\/accounts\/<strong>payments<\/strong>&nbsp;<\/p>\n\n\n\n<p>Although both are simply fine, plurals over singulars are widely accepted.&nbsp;<\/p>\n\n\n\n<p>To keep consistency, do not mix them in your URI architecture once you have made up your mind.&nbsp;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>IDs vs UUIDs in URIs<\/strong>&nbsp;<\/h2>\n\n\n\n<p>IDs pros and cons<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Pros<\/th><th>Cons<\/th><\/tr><\/thead><tbody><tr><td>Smaller<\/td><td>IDs are less flexible than UUIDs (exposes underlying technology used)&nbsp;<\/td><\/tr><tr><td>No brainer, already available&nbsp;<\/td><td>IDs are guessable (susceptible to web crawlers and bots)&nbsp;<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>UUIDs pros and cons<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Pros<\/th><th>Cons<\/th><\/tr><\/thead><tbody><tr><td>More flexible. (Migrating databases is less of a pain and won\u2019t compromise URI architecture)&nbsp;<\/td><td>Require more space in memory&nbsp;<\/td><\/tr><tr><td>Can\u2019t be simply guessed. (Resistance to crawlers)&nbsp;<\/td><td>Requires an initial setup&nbsp;<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong><strong>Representing DATA formats in a URL<\/strong>&nbsp;<\/strong><\/h2>\n\n\n\n<p>Adding data representation in the URL is a terrible idea.&nbsp;<\/p>\n\n\n\n<p class=\"has-vivid-red-color has-text-color\">\ud83d\udc4e <strong>BAD:<\/strong> &#8230;\/users\/vicentem.<strong>json<\/strong>&nbsp;<\/p>\n\n\n\n<p class=\"has-vivid-red-color has-text-color\">\ud83d\udc4e\ud83d\udc4e<strong> EVEN WORSE:<\/strong> \u2026\/users\/vicentem?<strong>format=json<\/strong>&nbsp;<\/p>\n\n\n\n<p>The HTTP protocol already defines the semantics to ask for different types of representation.&nbsp;<\/p>\n\n\n\n<p class=\"has-vivid-green-cyan-color has-text-color\">\ud83d\udc4d <strong>BETTER:<\/strong> Use the <strong>Accept (Accept-Language) headers<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>IDs vs UUIDs in URIs<\/strong>&nbsp;<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>If there are 2 URIs for the same resource, send the <strong>canonical URI<\/strong> to the client.&nbsp;<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Hyphens ( &#8211; )<\/strong> are more usable than underlines ( _ ).&nbsp;<\/li>\n\n\n\n<li>Use always <strong>lowercase<\/strong>.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Modeling Actions: Nouns vs Verbs AKA \u201cHow to model [&hellip;]<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","footnotes":""},"categories":[28,254],"tags":[43],"coauthors":[133],"class_list":["post-650","post","type-post","status-publish","format-standard","hentry","category-blog-post","category-engineering-practices","tag-api"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Good URI Practices | Infobip Developers Hub<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.infobip.com\/developers\/blog\/good-uri-practices-nouns-and-verbs-id-types-and-requesting-data-formats\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Good URI Practices | Infobip Developers Hub\" \/>\n<meta property=\"og:description\" content=\"Modeling Actions: Nouns vs Verbs AKA \u201cHow to model [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.infobip.com\/developers\/blog\/good-uri-practices-nouns-and-verbs-id-types-and-requesting-data-formats\" \/>\n<meta property=\"og:site_name\" content=\"Infobip Developers Hub\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/infobip\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-10-31T11:18:25+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-09-11T14:33:41+00:00\" \/>\n<meta name=\"author\" content=\"Infobip Devs\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@InfobipDev\" \/>\n<meta name=\"twitter:site\" content=\"@InfobipDev\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Infobip Devs\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.infobip.com\/developers\/blog\/good-uri-practices-nouns-and-verbs-id-types-and-requesting-data-formats#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.infobip.com\/developers\/blog\/good-uri-practices-nouns-and-verbs-id-types-and-requesting-data-formats\"},\"author\":{\"name\":\"Infobip Devs\",\"@id\":\"https:\/\/www.infobip.com\/developers\/#\/schema\/person\/e04a9012051f81b6a2f6976e156f6ce0\"},\"headline\":\"Good URI Practices: nouns and verbs, ID types, and requesting data formats\u00a0\",\"datePublished\":\"2022-10-31T11:18:25+00:00\",\"dateModified\":\"2023-09-11T14:33:41+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.infobip.com\/developers\/blog\/good-uri-practices-nouns-and-verbs-id-types-and-requesting-data-formats\"},\"wordCount\":441,\"publisher\":{\"@id\":\"https:\/\/www.infobip.com\/developers\/#organization\"},\"keywords\":[\"API\"],\"articleSection\":[\"Blog Post\",\"Engineering Practices\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.infobip.com\/developers\/blog\/good-uri-practices-nouns-and-verbs-id-types-and-requesting-data-formats\",\"url\":\"https:\/\/www.infobip.com\/developers\/blog\/good-uri-practices-nouns-and-verbs-id-types-and-requesting-data-formats\",\"name\":\"Good URI Practices | Infobip Developers Hub\",\"isPartOf\":{\"@id\":\"https:\/\/www.infobip.com\/developers\/#website\"},\"datePublished\":\"2022-10-31T11:18:25+00:00\",\"dateModified\":\"2023-09-11T14:33:41+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.infobip.com\/developers\/blog\/good-uri-practices-nouns-and-verbs-id-types-and-requesting-data-formats#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.infobip.com\/developers\/blog\/good-uri-practices-nouns-and-verbs-id-types-and-requesting-data-formats\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.infobip.com\/developers\/blog\/good-uri-practices-nouns-and-verbs-id-types-and-requesting-data-formats#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.infobip.com\/developers\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Good URI Practices: nouns and verbs, ID types, and requesting data formats\u00a0\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.infobip.com\/developers\/#website\",\"url\":\"https:\/\/www.infobip.com\/developers\/\",\"name\":\"Infobip Developers Hub\",\"description\":\"Build meaningful customer relationships across any channel\",\"publisher\":{\"@id\":\"https:\/\/www.infobip.com\/developers\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.infobip.com\/developers\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.infobip.com\/developers\/#organization\",\"name\":\"Infobip Developers Hub\",\"url\":\"https:\/\/www.infobip.com\/developers\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.infobip.com\/developers\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.infobip.com\/developers\/wp-content\/uploads\/2023\/03\/Infobip_logo_favicon.png\",\"contentUrl\":\"https:\/\/www.infobip.com\/developers\/wp-content\/uploads\/2023\/03\/Infobip_logo_favicon.png\",\"width\":696,\"height\":696,\"caption\":\"Infobip Developers Hub\"},\"image\":{\"@id\":\"https:\/\/www.infobip.com\/developers\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/infobip\/\",\"https:\/\/x.com\/InfobipDev\",\"https:\/\/www.youtube.com\/channel\/UCUPSTy53VecI5GIir3J3ZbQ\",\"https:\/\/github.com\/infobip-community\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.infobip.com\/developers\/#\/schema\/person\/e04a9012051f81b6a2f6976e156f6ce0\",\"name\":\"Infobip Devs\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.infobip.com\/developers\/#\/schema\/person\/image\/f61078713800c4e479dce745cd206b82\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/f29655934347a5aa15879f9af9ac1f05b87167e0f7ed4074a04132eaa9f631c4?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/f29655934347a5aa15879f9af9ac1f05b87167e0f7ed4074a04132eaa9f631c4?s=96&d=mm&r=g\",\"caption\":\"Infobip Devs\"},\"url\":\"https:\/\/www.infobip.com\/developers\/blog\/author\/infobip-devs\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Good URI Practices | Infobip Developers Hub","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.infobip.com\/developers\/blog\/good-uri-practices-nouns-and-verbs-id-types-and-requesting-data-formats","og_locale":"en_US","og_type":"article","og_title":"Good URI Practices | Infobip Developers Hub","og_description":"Modeling Actions: Nouns vs Verbs AKA \u201cHow to model [&hellip;]","og_url":"https:\/\/www.infobip.com\/developers\/blog\/good-uri-practices-nouns-and-verbs-id-types-and-requesting-data-formats","og_site_name":"Infobip Developers Hub","article_publisher":"https:\/\/www.facebook.com\/infobip\/","article_published_time":"2022-10-31T11:18:25+00:00","article_modified_time":"2023-09-11T14:33:41+00:00","author":"Infobip Devs","twitter_card":"summary_large_image","twitter_creator":"@InfobipDev","twitter_site":"@InfobipDev","twitter_misc":{"Written by":"Infobip Devs","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.infobip.com\/developers\/blog\/good-uri-practices-nouns-and-verbs-id-types-and-requesting-data-formats#article","isPartOf":{"@id":"https:\/\/www.infobip.com\/developers\/blog\/good-uri-practices-nouns-and-verbs-id-types-and-requesting-data-formats"},"author":{"name":"Infobip Devs","@id":"https:\/\/www.infobip.com\/developers\/#\/schema\/person\/e04a9012051f81b6a2f6976e156f6ce0"},"headline":"Good URI Practices: nouns and verbs, ID types, and requesting data formats\u00a0","datePublished":"2022-10-31T11:18:25+00:00","dateModified":"2023-09-11T14:33:41+00:00","mainEntityOfPage":{"@id":"https:\/\/www.infobip.com\/developers\/blog\/good-uri-practices-nouns-and-verbs-id-types-and-requesting-data-formats"},"wordCount":441,"publisher":{"@id":"https:\/\/www.infobip.com\/developers\/#organization"},"keywords":["API"],"articleSection":["Blog Post","Engineering Practices"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.infobip.com\/developers\/blog\/good-uri-practices-nouns-and-verbs-id-types-and-requesting-data-formats","url":"https:\/\/www.infobip.com\/developers\/blog\/good-uri-practices-nouns-and-verbs-id-types-and-requesting-data-formats","name":"Good URI Practices | Infobip Developers Hub","isPartOf":{"@id":"https:\/\/www.infobip.com\/developers\/#website"},"datePublished":"2022-10-31T11:18:25+00:00","dateModified":"2023-09-11T14:33:41+00:00","breadcrumb":{"@id":"https:\/\/www.infobip.com\/developers\/blog\/good-uri-practices-nouns-and-verbs-id-types-and-requesting-data-formats#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.infobip.com\/developers\/blog\/good-uri-practices-nouns-and-verbs-id-types-and-requesting-data-formats"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.infobip.com\/developers\/blog\/good-uri-practices-nouns-and-verbs-id-types-and-requesting-data-formats#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.infobip.com\/developers\/"},{"@type":"ListItem","position":2,"name":"Good URI Practices: nouns and verbs, ID types, and requesting data formats\u00a0"}]},{"@type":"WebSite","@id":"https:\/\/www.infobip.com\/developers\/#website","url":"https:\/\/www.infobip.com\/developers\/","name":"Infobip Developers Hub","description":"Build meaningful customer relationships across any channel","publisher":{"@id":"https:\/\/www.infobip.com\/developers\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.infobip.com\/developers\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.infobip.com\/developers\/#organization","name":"Infobip Developers Hub","url":"https:\/\/www.infobip.com\/developers\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.infobip.com\/developers\/#\/schema\/logo\/image\/","url":"https:\/\/www.infobip.com\/developers\/wp-content\/uploads\/2023\/03\/Infobip_logo_favicon.png","contentUrl":"https:\/\/www.infobip.com\/developers\/wp-content\/uploads\/2023\/03\/Infobip_logo_favicon.png","width":696,"height":696,"caption":"Infobip Developers Hub"},"image":{"@id":"https:\/\/www.infobip.com\/developers\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/infobip\/","https:\/\/x.com\/InfobipDev","https:\/\/www.youtube.com\/channel\/UCUPSTy53VecI5GIir3J3ZbQ","https:\/\/github.com\/infobip-community"]},{"@type":"Person","@id":"https:\/\/www.infobip.com\/developers\/#\/schema\/person\/e04a9012051f81b6a2f6976e156f6ce0","name":"Infobip Devs","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.infobip.com\/developers\/#\/schema\/person\/image\/f61078713800c4e479dce745cd206b82","url":"https:\/\/secure.gravatar.com\/avatar\/f29655934347a5aa15879f9af9ac1f05b87167e0f7ed4074a04132eaa9f631c4?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f29655934347a5aa15879f9af9ac1f05b87167e0f7ed4074a04132eaa9f631c4?s=96&d=mm&r=g","caption":"Infobip Devs"},"url":"https:\/\/www.infobip.com\/developers\/blog\/author\/infobip-devs"}]}},"_links":{"self":[{"href":"https:\/\/www.infobip.com\/developers\/wp-json\/wp\/v2\/posts\/650","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.infobip.com\/developers\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.infobip.com\/developers\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.infobip.com\/developers\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/www.infobip.com\/developers\/wp-json\/wp\/v2\/comments?post=650"}],"version-history":[{"count":4,"href":"https:\/\/www.infobip.com\/developers\/wp-json\/wp\/v2\/posts\/650\/revisions"}],"predecessor-version":[{"id":2535,"href":"https:\/\/www.infobip.com\/developers\/wp-json\/wp\/v2\/posts\/650\/revisions\/2535"}],"wp:attachment":[{"href":"https:\/\/www.infobip.com\/developers\/wp-json\/wp\/v2\/media?parent=650"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.infobip.com\/developers\/wp-json\/wp\/v2\/categories?post=650"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.infobip.com\/developers\/wp-json\/wp\/v2\/tags?post=650"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.infobip.com\/developers\/wp-json\/wp\/v2\/coauthors?post=650"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}