GithubHelp home page GithubHelp logo

ministac-api's Introduction

Ministac-api

*JSON REST API for ministac *

Resources

List of resources

Example usage with python

import requests
import datetime as dt
from pprint import pprint

# Get all available collections
r = requests.get('http://127.0.0.1:5000/ministac/api/v0/collections')
pprint(r.json())


# Get metadata of a collection
r = requests.get('http://127.0.0.1:5000/ministac/api/v0/collections/landsat_sr_8')
pprint(r.json())


# Get metadata of an item
r = requests.get('http://127.0.0.1:5000/ministac/api/v0/collections/landsat_sr_8/items/LC08_L1TP_028045_20171121_20171206_01_T1')
pprint(r.json())


# Search items using various filters
params = {'collection': 'landsat_sr_8',
          'maxCloudCover': 12,
          'endDate': dt.datetime(2017, 12, 1).isoformat()}

r = requests.post('http://127.0.0.1:5000/ministac/api/v0/search', json=params)
# Or
r = requests.get('http://127.0.0.1:5000/ministac/api/v0/search', params=params)

pprint(r.json())

Also see example (in spanish) at http://www.loicdutrieux.net/ministac-api/#/.

HTTP status codes

200: OK

400: Bad request

404: Not found

Install

You must first configure ministac (database setup and configuration file), then.

Locally

git clone [email protected]:loicdtx/ministac-api.git
cd ministac-api
pip install -r requirements.txt
pip install -e .
export FLASK_APP=api
flask run

Using docker

git clone https://github.com/loicdtx/ministac-api.git
cd ministac-api
docker build -t ministac-api:latest .
docker run --name ministac-api --rm -d -p 5000:5000 -v ~/.ministac:/root/.ministac ministac-api

Note:

This approach serves uwsgi binary protocol and must be combined with a nginx server.

Using docker-compose

First configure the nginx file, env_file and .ministac files. Then:

# Start the database container
docker-compose up -d db
# Create the ministac tables
docker-compose run --rm --entrypoint "python3" flaskapp -c "from ministac.db import init_db; init_db()"
# Start the cluster
docker-compose up -d

Note:

This approach serves uwsgi binary protocol and must be combined with a nginx server.

ministac-api's People

Contributors

loicdtx avatar

Watchers

 avatar  avatar

ministac-api's Issues

add in README next commands for nginx server

It will be useful to have next recommendations in README when using nginx

Conf file for nginx


upstream ministac {

     server <server where ministac-api is deployed>:5000; 

}

server {

...

 location /ministac/ {

        uwsgi_pass <server where ministac-api is deployed>:5000;

        include     ./uwsgi_params; 

    }

    

}

And create uwsgi_params (in the same directory of conf file for nginx):

uwsgi_param  QUERY_STRING       $query_string;
uwsgi_param  REQUEST_METHOD     $request_method;
uwsgi_param  CONTENT_TYPE       $content_type;
uwsgi_param  CONTENT_LENGTH     $content_length;

uwsgi_param  REQUEST_URI        $request_uri;
uwsgi_param  PATH_INFO          $document_uri;
uwsgi_param  DOCUMENT_ROOT      $document_root;
uwsgi_param  SERVER_PROTOCOL    $server_protocol;
uwsgi_param  REQUEST_SCHEME     $scheme;
uwsgi_param  HTTPS              $https if_not_empty;

uwsgi_param  REMOTE_ADDR        $remote_addr;
uwsgi_param  REMOTE_PORT        $remote_port;
uwsgi_param  SERVER_PORT        $server_port;
uwsgi_param SERVER_NAME         $server_name;

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.