Coder Social home page Coder Social logo

sup_authen's Introduction

Sup - a messaging API

Sup is a simple messaging API. Users can be created, updated, edited, and deleted. Messages can be sent between any two users of Sup.

API Documentation

Users endpoints

/users

Endpoint representing all users of Sup.

GET /users

Get an array of all users of Sup.

URL parameters:

None

Data parameters:

None

Query string parameters:

None

Returns:

An array of all users.

Example:

> GET /users

< Status: 200 OK
< [
<     {
<         "_id": "000000000000000000000000",
<         "username": "alice"
<     }
< ]

POST /users

Add a user to Sup

URL Parameters:

None

Data parameters:

  • The user to add

Query string parameters:

None

Returns:

An empty object.

Example:

> POST /users
> {
>     "username": "alice"
> }

< Status: 201 Created
< Location: /users/000000000000000000000000
< {
< }

/users/:userId

Endpoint representing a single user of Sup.

GET /users/:userId

Get a single user of Sup.

URL parameters:

  • userId - The ObjectId of the user.

Data parameters:

None

Query string parameters:

None

Returns:

A JSON object of the user.

Example:

> GET /users/000000000000000000000000

< Status: 200 OK
< {
<     "_id": "000000000000000000000000",
<     "username": "alice"
< }

PUT /users/:userId

Add or edit a Sup user.

URL parameters:

  • userId - The ObjectId of the user to add or edit.

Data parameters:

  • The user to add or edit

Query string parameters:

None

Returns:

An empty object.

Example:

> PUT /users/0000000000000000000000000
> {
>     "username": "alice"
> }

< Status: 200 OK
< {
< }

DELETE /users/:userId

Delete a Sup user.

URL parameters:

  • userId - The ObjectId of the user to delete.

Data parameters:

None

Query string parameters:

None

Returns:

An empty object.

Example:

> DELETE /users/0000000000000000000000000

< Status: 200 OK
< {
< }

Messages endpoints

/messages

Endpoint representing all messages in Sup.

GET /messages

Get an array of messages in Sup.

URL parameters:

None

Data parameters:

None

Query string parameters:

  • from - Only select messages from the user with the corresponding ObjectId
  • to - Only select messages to the user with the corresponding ObjectId

Returns:

An array of messages.

Example:

> GET /messages

< Status: 200 OK
< [
<     {
<         "_id": "000000000000000000000000",
<         "text": "Hi Bob",
<         "from": {
<             "_id": "0000000000000000000000000",
<             "username": "alice"
<         },
<         "to": {
<             "_id": "1111111111111111111111111",
<             "username": "bob"
<         }
<     }
< ]

POST /messages

Add a message.

URL Parameters:

None

Data parameters:

  • The message to add, with a sender and recipient

Query string parameters:

None

Returns:

An empty object.

Example:

> POST /messages
> {
>     "text": "Hi Bob",
>     "from": "0000000000000000000000000",
>     "to": "1111111111111111111111111"
> }

< Status: 201 Created
< Location: /messages/000000000000000000000000
< {
< }

/message/:messageId

Endpoint representing a single message.

GET /messages/:messageId

Get a single message.

URL parameters:

  • messageId - The ObjectId of the message.

Data parameters:

None

Query string parameters:

None

Returns:

A JSON object of the message.

Example:

> GET /messages/000000000000000000000000

< Status: 200 OK
< {
<     "_id": "000000000000000000000000",
<     "text": "Hi Bob",
<     "from": {
<         "_id": "0000000000000000000000000",
<         "username": "alice"
<     },
<     "to": {
<         "_id": "1111111111111111111111111",
<         "username": "bob"
<     }
< }

Error objects

If an error occurs then the API will send a JSON error object in the following format, with an appropriate status code:

{
    "message": "A description of the error"
}

sup_authen's People

Contributors

alexbang-git avatar ericsnell avatar

Watchers

 avatar  avatar  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.