Giter Site home page Giter Site logo

restapi-structure-guideline's Introduction

RestAPI-Structure-Guideline

Guideline for creating REST API endpoints.

  • URL structure should include api version number, eg. /v1/
  • All GET methods should support limit and offset query string parameters, and have default values in case of absence. Sorting
  • POST - new item, PUT - update, DELETE - remove, GET.
  • In case query string params contain ?_method=DELETE, use method DELETE.

API Authentication

  • AuthKey Token as a request header.

POST /auth/signup - new admin user

GET /auth/verifyemail/:verifcode - activate account

POST /auth/signin - login user (all types)

response

HEADERS: Set-Cookie: 'AuthKey=asdkljqldalskdjasd'

{status: 'ok', AuthKey: 'asdkljqldalskdjasd'}

GET /auth/signout - logout user

HEADERS: x-AuthKey: 'asdkljqldalskdjasd'

POST /auth/passrecovery - send pass recovery email

GET /auth/passrecovery/:chPassReqVerifCode - show form ({status: true, verifCode})

POST /auth/restpass (verifCode, new password) - rest pass /users/current - GET (current logged in user info)

API endpoints

/v1/users - POST

/v1/users/2222 - PUT, DELETE, GET

All API GET endpoints should implement COUNT, number of items.

/v1/users/count

API resources - nouns, actions - verbs

GET /v1/dogs/13123

POST /v1/dogs/register

ALL API GET endpoints should handle these params

?page=nnnn

Response Codes

HTTP: 200, { status: “ok”, data: [] }

HTTP: 200, { status: “error”, message: “Error message“, error_code: 231 }

Return fields filter response_fields=[ short | long | public ]

restapi-structure-guideline's People

Contributors

emarukyan avatar

Stargazers

Eric avatar

Watchers

 avatar

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.