Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ushahidi/crisisnet
CrisisNET public API
https://github.com/ushahidi/crisisnet
Last synced: 2 months ago
JSON representation
CrisisNET public API
- Host: GitHub
- URL: https://github.com/ushahidi/crisisnet
- Owner: ushahidi
- Created: 2014-02-24T05:52:08.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-03-18T13:34:28.000Z (almost 10 years ago)
- Last Synced: 2024-11-04T03:32:37.431Z (3 months ago)
- Language: JavaScript
- Size: 2.14 MB
- Stars: 28
- Watchers: 21
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-starred - ushahidi/crisisnet - CrisisNET public API (others)
README
# CrisisNET
#### A firehose of worldwide crisis data.
[CrisisNET](http://crisis.net) gives app developers, data-journalists and other makers fast, easy access to critical government, business, humanitarian, and crowdsourced data. Our API reduces the time it takes to access and use crisis-relevant data from hours (even days) to minutes.
## Getting Started
Register for an API key using [our developer portal](http://devapi.crisis.net/). (Note: we're currently in private beta, so the portal is a work in progress.)
## Getting Data
Now that you have an API key, CrisisNET data is yours for the taking. You'll find more detailed instructions below, but a basic request looks like this:
$.ajax({
url: 'http://api.crisis.net/item?apiKey='+ YOUR_TOKEN_HERE+'location=36.821946,-1.292066',
dataType: "json",
success: function (data) {
console.log(data);
}
});The above request is in JavaScript (using jQuery), so you'd run that from a web browser. However, because CrisisNET is a REST API, you can access it using any language that can make HTTP requests (Python, PHP, Java, etc etc). Here's the same example in Python, just for fun:
import requests
url = 'http://devapi.crisis.net/item&location=36.821946,-1.292066'
headers = {'Authorization': 'Bearer ' + YOUR_TOKEN_HERE}r = requests.get(url, headers=headers)
## Filtering Data
As you probably noticed above, both requests are to the `/item` endpoint. In CrisisNET, an `Item` resource is very general -- basically a thing that exists in a place (usually at a specific time). This might be a tweet or Facebook status, a news item, NGO survey response, entry from a municipal dataset, etc etc. In this way we give you the power to shape your data stream in whatever way makes the most sense for your use case.
### List 'O Filters
Name | Description | Type/Example
--- | --- | ---
*before* | Only retrieve records before this date/time. | timestamp in ISO 8601 format: `YYYY-MM-DDTHH:MM:SSZ` eg `before=2014-02-10T10:50:42.389Z`
*after* | Only retrieve records after this date/time. | timestamp like `before`
*tags* | Get records matching *all* of these tags. | comma-separated list of strings eg `tags=health,injury`
*text* | Full-text search on title + text properties. | url-formatted string eg `text=needle+in+haystack`
*location* | Coordinates around which to search. | coordinate pair of longitude, latitude eg `location=36.821946,-1.292066`
*radius* | Get records within x meters of `location`. Defaults to 10. | number in meters, eg `radius=10`
*limit* | Limits the number of records returned. Defaults to 25. | number, eg `limit=100`
*offset* | Useful in conjunction with `limit` for paginatated through results. | number, eg `offset=25`
*sources* | Limit results based on where they originated (outside of CrisisNET) | comma-separated list of strings eg `sources=twitter,facebook`
*licenses* | Limit to records with specific licenses. Useful if you're looking for data to use commercially, for example. | comma-separated list of strings, eg `licenses=commercial,odbl`
*orderBy* | Property used to order result set. Deafults to `publishedAt` | any valid property name, eg `orderBy=title`### Example response
[
{
"source": "twitter",
"language": {
"code": "en"
},
"geo": {
"locationIdentifiers": {
"authorLocationName": "Nairobi, Kenya",
"authorTimeZone": null
},
"coordinates": null
},
"content": "Three killed in an accident along Narok-Mai Mahiu Highway #NarokNorthDistrictHospitalMortuary #Kenya http://t.co/IQROp0sdWK",
"lifespan": "temporary",
"publishedAt": "Sat Feb 22 2014 12:25:30 GMT-0600 (CST)",
"remoteID": "437226684211662848"
},
{
"source": "twitter",
"language": {
"code": "en"
},
"geo": {
"locationIdentifiers": {
"authorLocationName": "Nairobi, Kenya",
"authorTimeZone": null
},
"coordinates": null
},
"content": "Three killed in an accident along Narok-Mai Mahiu Highway #NarokNorthDistrictHospitalMortuary #Kenya http://t.co/IQROp0sdWK",
"lifespan": "temporary",
"publishedAt": "Sat Feb 22 2014 12:25:30 GMT-0600 (CST)",
"remoteID": "437226684211662848"
}
]## Local Env setup:
### Requirements:
- Node.js 10.25+
- Python 2.7+### MacOS
Setup Mongo, ElasticSearch and Redis
brew install mongodb
brew install elasticsearch
brew install redisStart databases
redis-server /usr/local/etc/redis.conf
mongod
elasticsearch --config=/usr/local/opt/elasticsearch/config/elasticsearch.ymlContinue with Get Project Code
### Linux (Debian Testing/jessie)
Setup Mongo, ElasticSearch and Redis
sudo apt-get install mongodb redis-server
Add the elasticsearhc repo to your environment and install using the instructions [on the elasticsearch site](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/setup-repositories.html)Start databases
redis-server /etc/redis/redis.conf
mongod
sudo /usr/share/elasticsearch/bin/elasticsearch --config=/etc/elasticsearch/elasticsearch.ymlGet Project Code
git clone https://github.com/ushahidi/suckapy.git
git clone https://github.com/ushahidi/crisisnet.git
git clone https://github.com/ushahidi/scheduler.git
git clone https://github.com/ushahidi/grimlock.gitInstall dependencies
cd crisisnet
npm installcd ../scheduler
npm installcd ../grimlock
virtualenv venv --distribute
source venv/bin/activate
pip install -r requirements.txtcd ../suckapy
virtualenv venv --distribute
source venv/bin/activate
pip install -r requirements.txtRunning apps
--
cd into the project directory for the app you'd like to run and...Node apps
npm run-script dev-serverPython apps (make sure to start your virtualenv source venv/bin/activate)
python src/app.pyTesting apps
--
Node projects
npm run-script run-testPython projects
nosestestsDeploy code:
--
cd into the project you want to deploy
fab staging deploy:master(that means, deploy the master branch to the staging server)