Giter Club home page Giter Club logo

rest's Introduction

Representational State Transfer (REST) Guidelines

Find the website at https://retrosight.github.io/rest/

Welcome...!

This is a set of guidelines and resources for building a server that can participate in a REST paradigm.

  • The Guidelines leverage the Representational State Transfer (REST) dissertation by Fielding to craft an API accounting for the Null Style, Client-Server (CS), Stateless, Cache and Uniform Interface constraints.
  • Service Index documents provide a fundamental starting place for the programmable internet like home pages do at root URLs for the World Wide Web used by humans with browsers.
  • The Hypermedia as the Engine of Application State Model builds out the work of Stefan Tilkov from his excellent talk GOTO 2014 • REST: I don't Think it Means What You Think it Does. You can find my summary of his slides here.
  • Resources and Representations provides an example of how there can be one resource with many representations as well as how to bring together data from two distinct resources into a single representation for client code to use.
  • Hyperlinks are rather ubiquitous in REST and it can get confusing so Comparing Hyperlinks: Identifiers, Related Data and Hypermedia As The Engine Of Application State attempts to disambiguate for the reader.
  • Pagination elaborates on how the server controls pagination rather than putting it in the hands of the client.
  • Search is an important way an API allows client code to discover resources based on criteria.
  • JSON Schema resources which are used in the design -- see http://json-schema.org/ for more information on this emerging standard.
  • Also in the repository:
    • A Day of REST is a set of slides used in a five hour course I teach. It's very useful as an introduction to the key concepts and constraints of REST design.
    • Design Thoughts - A collection of mostly readings from folks who influenced the overall design you find here.
    • Documentation Template - Lists out all the basics an API should cover within its documentation and it includes all of the HTTP headers and status codes as hyperlinks to the various RFCs that cover same.
    • JSON Web Tokens are becoming more commonplace for access tokens included in an Authorization Header -- find a TL;dr explanation within JWT Summary.

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms. Learn more at https://www.contributor-covenant.org/.


MIT License

Copyright (c) 2019 Charlie Owen

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

rest's People

Contributors

retrosight avatar

Stargazers

Nick Sjostrom avatar  avatar Elle Meredith avatar Tanaka Tatsuya avatar Rafał Pocztarski avatar Alexei Grigoriev avatar Xavier Fornés avatar

Watchers

Richard Gibson avatar Alexei Grigoriev avatar  avatar  avatar  avatar

rest's Issues

Only recommend RFC 3339

From @gibson042

Also, a question: given that RFC 3339 is a well-defined and interoperable profile of ISO 8601, why would you recommend any other ISO 8601 representation?

JSON arrays should appear as a property of an object ( e.g., "items": [ ] ) in order to support metadata describing the collection itself

From @gibson042

I disagree with you on https://github.com/retrosight/rest/blob/primary/guidelines.md#resource-array (IMO, JSON arrays should appear as a property of an object [e.g., "items"] in order to support metadata describing the collection itself) — you actually already do this at https://github.com/retrosight/rest/blob/primary/guidelines.md#example-2, but it should be consistent everywhere.

Document usage of access tokens (like JWT) as part of the request / query.

This data is in fact implicitly associated with {value}. The {value} is read from the access token (JWT) and the results are filtered to only include {value}.

  • “Implicitly”: That’s the challenge I have with this approach – it’s quite opaque.
    • Until you told me I didn’t know you were using the access token to augment the URI.
  • When that data is passed around it might have a different access token in the token OR the client code doesn’t record the token with the data.
    • The relationship you intend to note is lost at this point.
  • I do not suggest we use access tokens in this manner – it’s effectively using a JWT as a query mechanism.
    • The access token should only be used to authorize the request, not as part of an identifier.
  • What you really want is this: GET https://invoice-payment-metadata-rqa3.concurasp.com/payments?companyId=some-value
    • By doing so, the authorization mechanism can totally change and the API keeps working without changes.

Generally speaking, the interface of the API should be designed without regards to the authorization used – this will avoid a lot of pitfalls.

Advise against universally significant query parameters (e.g., `representation`) except when prefixed by a reserved sequence (e.g., `_` or `$`), to avoid semantic collisions

From @gibson042

I would also advise against universally significant query parameters (e.g., representation) except prefixed by a reserved sequence (e.g., _ or $), to avoid semantic collisions (for that matter, the same principle also applies to resource field naming as well, but that list of reserved names is more manageable so it's not as important)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.