Code Monkey home page Code Monkey logo

nodejs's Introduction

nodejs

.INTRODUCTION A simple documentation of the API is this document, made with the Node.js language. In the following lines I will show you how to test with different methods and types of status codes.

.ENDPOINTS The Data Quality APIs (like any other API) are based on an event-driven architecture. They are triggered when an event occurs. So whenever new data arrives through a connected application or existing data is updated, it first passes through the API (where the data quality is checked) and then is directed to the source database. The API thus acts as a bridge between a data capture application and a data storage source, ensuring that no data quality errors are transferred from the first endpoint to the second. An API endpoint is a digital location exposed via the API from which the API receives requests and sends responses. Each endpoint is a Uniform Resource Locator (URL) that provides the location of a resource on the API server.

REQUESTS-METHODS

The request method is how we distinguish the type of action we are "asking" our endpoint to perform. For example, the GET method stands on its own. But we also have a few other methods that we use quite often. such as Post put ... .

Method Description GET Used to retrieve information about a player. POST Used when inserting in the database a new data, for example the name and information of a new footballer PUT Used to replace an entire element (all fields) with new data. For example, changing the age or number of wins (etc ...) of a player DELETE Used to delete an item. Examples

Now that we have learned the different query methods to use, we will give some examples:

Method URL Description

GET /api/v1/stats/id Retrieve all information from the player with the selected id. POST /api/v1/stats Create a new post. PUT /api/v1/stats/id edit post id. DELETE /api/v1/stats/id DELETE post id. real-time_example

*GET method :

-- get the information of the players with id = 101

https://app-nodjs.herokuapp.com this is the result:

{ "id": 101, "wins": 10, "losses": 3, "points_scored": 7 }

*POST method : -- Create a new post with id = 101

https://app-nodjs.herokuapp.com

the new post you want to send { "id": 101, "wins": 10, "losses": 3, "points_scored": 7 }

*PUT method :

-- edit post with id = 101

https://app-nodjs.herokuapp.com

{ "id": 101, "wins": 10, "losses": 3, "points_scored": 7 }

*DELETE method :

-- Delete a post with id = 101

Code 200 to let you know that you have indeed deleted the post

Status Codes

the status codes and their meaning if you see them on the postman test or other test :

Code Title Description 200 OK When a request was successfully processed (e.g. when using GET, PATCH, PUT or DELETE). 201 Created Every time a record has been added to the database (e.g. when creating a new user or post). 404 Not found When URL or entity is not found. 500 Internal server error When an internal error has happened (e.g. when trying to add/update records in the database fails).

nodejs's People

Contributors

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