{"id":40121,"date":"2023-07-21T16:13:17","date_gmt":"2023-07-21T20:13:17","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=40121"},"modified":"2023-07-21T16:13:17","modified_gmt":"2023-07-21T20:13:17","slug":"advice-for-operating-a-public-facing-api","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2023\/07\/21\/advice-for-operating-a-public-facing-api\/","title":{"rendered":"Advice for Operating a Public-Facing API"},"content":{"rendered":"<p><a href=\"https:\/\/jcs.org\/2023\/07\/12\/api\">Joshua Stein<\/a>:<\/p>\n<blockquote cite=\"https:\/\/jcs.org\/2023\/07\/12\/api\"><p>Serve your API at <code>api.example.com<\/code>, never at <code>example.com\/api<\/code>. As your API&rsquo;s usage grows, it will expand beyond your website\/dashboard server and need to move to a separate server or many separate servers. [&#8230;] Your API may also have more relaxed security restrictions in terms of TLS versions and ciphers accepted that you don&rsquo;t want to relax on your dashboard website that handles sensitive information.<\/p><p>[&#8230;]<\/p><p>Rather than bending over backwards <a href=\"https:\/\/en.wikipedia.org\/wiki\/Robustness_principle\">trying to support poorly written code<\/a>, don&rsquo;t let their bad code function properly in the first place so it doesn&rsquo;t get deployed.<\/p><p>[&#8230;]<\/p><p>With OAuth your API can&rsquo;t be used from a <a href=\"https:\/\/pushover.net\/splash#integration\">simple curl request<\/a> but has to be a custom multi-step process pulling in a whole OAuth library. Use static API tokens if you can, but make it easy to rotate them.<\/p><p>[&#8230;]<\/p><p>[Generate] a unique ID or UUID with every request, return it to the user in the message body somewhere, log it, and ask for it on your support form.<\/p><p>[&#8230;]<\/p><p>[Use] a short prefix for each type of random ID you create.<\/p><\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Joshua Stein: Serve your API at api.example.com, never at example.com\/api. As your API&rsquo;s usage grows, it will expand beyond your website\/dashboard server and need to move to a separate server or many separate servers. [&#8230;] Your API may also have more relaxed security restrictions in terms of TLS versions and ciphers accepted that you don&rsquo;t [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2023-07-21T20:13:20Z","apple_news_api_id":"41c8672e-5d60-428d-8697-497ec8fc48fa","apple_news_api_modified_at":"2023-07-21T20:13:20Z","apple_news_api_revision":"AAAAAAAAAAD\/\/\/\/\/\/\/\/\/\/w==","apple_news_api_share_url":"https:\/\/apple.news\/AQchnLl1gQo2Gl0l-yPxI-g","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[27,959,71,50],"class_list":["post-40121","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-craft","tag-oauth","tag-programming","tag-webapi"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/40121","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=40121"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/40121\/revisions"}],"predecessor-version":[{"id":40122,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/40121\/revisions\/40122"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=40121"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=40121"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=40121"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}