Git Product home page Git Product logo

wind-api's Introduction

windforlife-Ludovic-Py

Getting started


First, at the root of the project, duplicate or rename the file .env.dev in .env

To launch the project, in your terminal, run the following command to build and start the Docker containers:

docker-compose up -d --build

When the containers running, make all the migration:

docker-compose exec api python manage.py migrate

Then load the json file data.json it contain all the data necessary to test the project:

docker-compose exec api python manage.py loaddata data.json

Authentication


To use the API you need to create an account to get the auth token, however an account is already available if you want:

You need a basic auth (username, password) to get the token, so there is a cURL request to get it:

curl -X POST \
  'http://localhost:8000/auth-token/' \
  --header 'Content-Type: application/json' \
  --data-raw '{
  "username": "root",
  "password": "password"
}'

And the return of this request, save the token because you need it for every following requests:

{
  "token": "23debdb9888b1561785d572a22cee52079feaee1"
}

Consume API


Once you have the token you can consume the endpoints of the API

here is one exemple, if you use Thunder-Client for VScode you can import all endpoints collection from the file thunder-collection_Wind_For_Life.json (I dont know if work for Postman...)

To list all Anemometers:

curl -X GET \
  'http://localhost:8000/api/anemometers/' \
  --header 'Authorization: Token 23debdb9888b1561785d572a22cee52079feaee1'

And you get a response like this:

[
  {
    "id": 1,
    "name": "Rue Rousseau",
    "coordinates": "SRID=4326;POINT (-12.2 2.34)",
    "tags": [
      "Perpignan"
    ],
    "daily_average": 4.0,
    "weekly_average": 7.833333333333333
  },
  {
    "id": 2,
    "name": "Avenue Bruges",
    "coordinates": "SRID=4326;POINT (-12.1 2.34)",
    "tags": [
      "Paris"
    ],
    "daily_average": null,
    "weekly_average": null
  }
  ...

wind-api's People

Contributors

pykix avatar

Watchers

Bruno Martin 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.