opendataphilly / Open-Data-Catalog

Open Data Catalog is an open data catalog based on Django, Python and PostgreSQL. It was originally developed for OpenDataPhilly.org, a portal that provides access to open data sets, applications, and APIs related to the Philadelphia region. The Open Data Catalog is a generalized version of the original source code with a simple skin. It is intended to display information and links to publicly available data in an easily searchable format. The code also includes options for data owners to submit data for consideration and for registered public users to nominate a type of data they would like to see openly available to the public.
http://www.opendataphilly.org/
MIT License
244 stars 90 forks source link

REST API for Open Data Catalog #1

Closed ahinz closed 12 years ago

ahinz commented 13 years ago

A Django app that provides REST based web services for the open data catalog All URLs support only the GET method unless otherwise noted. In addition, all GET services generate JSON responses and all PUT/POST services consume JSON.

To enable the API app add api to INSTALLED_APPS

Authentication

REST service authentication is done using HTTP Basic Authentication (and really should be done over https, but opendataphilly sends login credentials in the clear right now)

Resources

api/resources/ - Get a list of resources (data sets) api/resources/{id}/ - Get all information about a specific resource api/resources/search?qs={search query} - Search for resources that contain the given search query

Tags

api/tags/ - Get a list of tags api/tags/{tag name}/ - Get a list of Resources associated with a given tag name

Ideas

api/ideas/ - Get a list of ideas api/ideas/{id} - Get all information (including pictures, etc) about an Idea with the given id

Suggestions

api/suggestions/ - GET - List all suggestions api/suggestions/ - POST (Authentication Required) - Create a new suggestion api/suggestions/search?qs={search query} - Search suggestions for the given query api/suggestions/{id}/ - Get all information about the given suggestion api/suggestions/{id}/vote - PUT (Authentication Required) - Vote for the given suggestion. Users can call this method as often as they would like but the maximum number of votes recorded for a given user is 1. Returns the updated suggestion api/suggestions/{id}/vote - DELETE (Authentication Required) - Remove vote for the given suggestion. This method may be called more than once and since a user can only have 1 vote the result will always be the same. Returns the updated suggestion.

Submit Data Sets

api/submit/ - POST (Authentication Required) - Submit a new dataset to be approved

Testing

I'm not sure why but running python manage.py test fails due to paginator and a few other django.contrib modules. So to run the tests for just the api app:

python manage.py test api

As a side note, this is my first time using django and python so some of the code can probably be a lot more Pythonic/Djangoian

alsaihn commented 13 years ago

Thanks for the pull request! I'll take a look at the changes some time this week.