Skip to content

loicdtx/ministac-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 git@github.com: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.

About

JSON REST API for ministac catalog

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published