{"id":26719048,"url":"https://github.com/psenger/best-practices-for-rest-api","last_synced_at":"2026-02-06T09:36:26.150Z","repository":{"id":147705831,"uuid":"43495015","full_name":"psenger/Best-Practices-For-Rest-API","owner":"psenger","description":"Best Practices for Building REST Apis","archived":false,"fork":false,"pushed_at":"2025-12-16T04:17:58.000Z","size":106,"stargazers_count":24,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-12-19T15:13:30.904Z","etag":null,"topics":["api","rest","rest-api","restful"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/psenger.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-10-01T12:25:57.000Z","updated_at":"2025-12-16T04:19:48.000Z","dependencies_parsed_at":"2023-05-27T04:45:53.079Z","dependency_job_id":null,"html_url":"https://github.com/psenger/Best-Practices-For-Rest-API","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/psenger/Best-Practices-For-Rest-API","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psenger%2FBest-Practices-For-Rest-API","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psenger%2FBest-Practices-For-Rest-API/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psenger%2FBest-Practices-For-Rest-API/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psenger%2FBest-Practices-For-Rest-API/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/psenger","download_url":"https://codeload.github.com/psenger/Best-Practices-For-Rest-API/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psenger%2FBest-Practices-For-Rest-API/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29157426,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-06T07:18:23.844Z","status":"ssl_error","status_checked_at":"2026-02-06T07:13:32.659Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","rest","rest-api","restful"],"created_at":"2025-03-27T17:51:13.802Z","updated_at":"2026-02-06T09:36:26.142Z","avatar_url":"https://github.com/psenger.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Best Practices for Building REST APIs\n\n[![License: CC BY 4.0](https://img.shields.io/badge/License-CC_BY_4.0-lightgrey.svg)](https://creativecommons.org/licenses/by/4.0/)\n\nWritten by [Philip A Senger](https://psenger.github.io/philip_a_senger_cv/) | [LinkedIn](https://www.linkedin.com/in/philipsenger/) | [GitHub](https://github.com/psenger/)\n\nI've been building APIs for Service Oriented Applications for two decades. Many API design opinions and guidelines I have found are either academic in nature or less real world or practical. My goal with this document is to describe my version of best practices for a pragmatic API approach based on my experience and as a framework for my thoughts. I've found the following items to be the key to the success of my systems: The Human Aspect, Security and Permissions, and Implementation.\n\n## Table of Contents\n\n1. [The Human Aspect](docs/01-human-aspect.md)\n   - Adoption, Ease of Use, Documentation, Stability, Assurance\n   - Intuitive Design\n   - Consistency and Documentation\n\n2. [Pragmatism](docs/02-pragmatism.md)\n   - Avoid Dependency Bloat\n   - Framework Lock-in\n   - Build vs Buy\n   - AI-Assisted API Development\n\n3. [Security and Permissions](docs/03-security.md)\n   - Security Principles (Zero Trust, Defense in Depth, CIA Triad, Fail Secure)\n   - Authentication vs Authorisation\n   - Circles of Trust\n   - Passwords and OTP\n   - Tokens (Signature Verification, JTI, Storage, Access/Refresh, JWS/JWE)\n   - Risk-Based Assessment (RBA)\n   - Perimeter vs Distributed Security\n   - IAM, Identity, and PAM\n   - Rate Limiting and Device Fingerprinting\n   - Session Management\n\n4. [Design Principles](docs/04-design-principles.md)\n   - Contract-First Development\n   - Domain-Driven Design\n   - API as a Product\n   - Standards and Consistency (Naming, Versioning, CRUD)\n   - Self Discovery and HATEOAS (with trade-offs)\n   - Idempotency\n   - Conditional Requests\n   - CORS, Health Checks, Request Tracing\n\n5. [Resilience](docs/05-resilience.md)\n   - Service Unavailable\n   - Exponential Backoff with Jitter\n   - Circuit Breaker Pattern\n   - Graceful Degradation\n   - Timeouts and Bulkheads\n   - Caching (Headers, Layers, Invalidation, Stampedes)\n\n6. [Payloads and Errors](docs/06-payloads-and-errors.md)\n   - Response Structure (Envelope vs No Envelope)\n   - Field Selection (Projection)\n   - Pagination (Offset, Cursor, Link-based, Header-based)\n   - Errors (RFC 9457 Problem Details)\n   - Identifiers (UUIDs, Type-prefixed IDs)\n   - Content Negotiation\n\n7. [GraphQL vs REST](docs/07-graphql-vs-rest.md)\n   - Analysis of both approaches\n   - GraphQL Performance Issues (N+1, Query Complexity, Caching)\n   - When to Choose What\n   - Common Anti-Patterns\n\n8. [API Gateways](docs/08-api-gateways.md)\n   - What API Gateways Do\n   - Common Products (Apigee, Kong, AWS API Gateway, Azure APIM)\n   - Gateway Patterns (Proxy, Transformation, Aggregation, Pipeline)\n   - Pros and Cons\n   - When to Use (and When to Skip)\n\n9. [Glossary](docs/09-glossary.md)\n   - Technical terms, acronyms, and concepts (mTLS, PKCE, JTI, HATEOAS, OAuth, JWT, and more)\n\n---\n\n## License\n\nThis work is licensed under a [Creative Commons Attribution 4.0 International License](https://creativecommons.org/licenses/by/4.0/).\n\nYou are free to share and adapt this material for any purpose, even commercially, as long as you give appropriate credit to the original author.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpsenger%2Fbest-practices-for-rest-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpsenger%2Fbest-practices-for-rest-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpsenger%2Fbest-practices-for-rest-api/lists"}