Name: cfapi
Owner: Code for Japan
Description: The Code for America API. Tracks and motivates activity and participation across the civic technology movement.
Created: 2015-12-19 08:49:55.0
Updated: 2015-12-19 08:49:56.0
Pushed: 2015-12-18 23:20:58.0
Homepage: http://codeforamerica.org/api
Size: 1356
Language: Python
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Code for America has developed this API to track all the activity across the civic technology movement. Our goal is to measure and motivate the movement by recognizing participation. The CFAPI describes an organization's projects, stories, and events.
The tools that the Brigades and other groups use to do their fine deeds are all different. The CFAPI does the difficult job of being able to track these activities no matter what tools an organization is using. The participants don't need to change their activities to be included.
To get the information for the CfAPI, Code for America maintains a list of civic tech organizations and once an hour checks their activity on Meetup.com, their blog, and their GitHub projects. Other services and support for noncode projects are slowly being added. More technical details below.
See the full documentation at http://codeforamerica.org/api
Response for http://codeforamerica.org/api/organizations/Code-for-San-Francisco
ll_events": "http://codeforamerica.org/api/organizations/Code-for-San-Francisco/events",
ll_issues": "http://codeforamerica.org/api/organizations/Code-for-San-Francisco/issues",
ll_projects": "http://codeforamerica.org/api/organizations/Code-for-San-Francisco/projects",
ll_stories": "http://codeforamerica.org/api/organizations/Code-for-San-Francisco/stories",
pi_url": "http://codeforamerica.org/api/organizations/Code-for-San-Francisco",
ity": "San Francisco, CA",
urrent_events": [
{
"api_url": "http://codeforamerica.org/api/events/710",
"created_at": "2014-02-26 21:05:21",
"description": null,
"end_time": null,
"event_url": "http://www.meetup.com/Code-for-San-Francisco-Civic-Hack-Night/events/193535742/",
"id": 710,
"location": null,
"name": "Weekly Civic Hack Night",
"organization_name": "Code for San Francisco",
"start_time": "2014-08-27 18:30:00 -0700"
},
...
urrent_projects": [
{
api_url: "http://codeforamerica.org/api/projects/122",
categories: null,
code_url: "https://github.com/sfbrigade/localfreeweb.org",
description: "Front end for the Local Free Web project",
github_details: { ... },
id: 122,
issues: [ ... ],
last_updated: "Thu, 24 Jul 2014 22:01:17 GMT",
link_url: null,
name: "localfreeweb.org",
organization: {},
organization_name: "Code for San Francisco",
tags: ["digital access","bus stops"],
type: null,
status: "Official"
},
...
urrent_stories": [
{
"api_url": "http://codeforamerica.org/api/stories/10",
"id": 10,
"link": "https://groups.google.com/d/msg/code-for-san-francisco/9OewkHV-D1M/0UW_ye9UXc8J",
"organization_name": "Code for San Francisco",
"title": "Hack Night Project Pick List",
"type": "blog"
},
...
d" : "Code-for-San-Francisco",
vents_url": "http://www.meetup.com/Code-for-San-Francisco-Civic-Hack-Night/",
ast_updated": 1409087294,
atitude": 37.7749,
ongitude": -122.4194,
ame": "Code for San Francisco",
ast_events": "http://codeforamerica.org/api/organizations/Code-for-San-Francisco/past_events",
rojects_list_url": "https://docs.google.com/spreadsheet/pub?key=0ArHmv-6U1drqdDVGZzdiMVlkMnRJLXp2cm1ZTUhMOFE&output=csv",
ss": "",
tarted_on": "2014-07-30",
ype": "Brigade",
pcoming_events": "http://codeforamerica.org/api/organizations/Code-for-San-Francisco/upcoming_events",
ebsite": "http://codeforsanfrancisco.org/"
The need for a way to show off good civic tech projects was apparent. Several Brigades had all started working on ways to track their projects. They were working separately on the same idea at the same time. The CFAPI is a generalization of the great work done by:
*For the full story behind this API, read this.
This repository is forked from Open City's Civic Json Worker
We hope that this experiment of tracking activity within a community is useful for other groups besides the civic technology movement. We will begin working with other groups to see if an instance of the CfAPI is useful for them.
We also want to add support for many more services to be included, such as events from Eventbrite. Our goal is for any organization to use any tool to do their work and we will integrate with them.
The new site will be powered by this Brigade Information Google Spreadsheet. This way you don't need yet another account for our Brigade site. Just keep your Brigade's info up to date and you're good. Email andrewh@codeforamerica.org if you want permission to add and edit groups.
The columns are:
https://groups.google.com/forum/feed/code-for-san-francisco/msgs/rss.xml?num=15
https://github.com/sfbrigade
or a link to a list of project URLs, described below.This projects list you point us to will need the following columns:
name
- filled in by GitHub if left blankdescription
- filled in by GitHub if left blanklink_url
- filled in by GitHub if left blankcode_url
- Only GitHub links work for now. Others will be added as needed later.tags
- Catch-all project tagging, terms separated by commas. “Education, digital literacy, iOS, Kansas City”status
- Whatever status names you use, e.g., “Alpha, Beta, Launched, In Progress”An example:
, description, link_url, code_url, type, categories, tags, status
h Bend Voices, "A redeploy of CityVoice for South Bend, IN.", http://www.southbendvoices.com/, https://github.com/codeforamerica/cityvoice,,, "community engagement, housing, mapping, ruby" "In progress"
That projects list URL can be any flavor of csv. The easiest way is to make a Google Spreadsheet like my example and then select File > Publish it to the web.
If you are using the new Google Spreadsheets, add /export?format=csv
to the end.
https://docs.google.com/spreadsheets/d/<key>/export?format=csv
If you have the older Google Drive version change ?output=html
to ?output=csv
.
https://docs.google.com/spreadsheet/pub?key=<key>?output=csv
Put that in the Brigade Information sheet and you're done.
The projects list URL can also be a JSON file, with a list of strings containing GitHub project URLs.
Lastly, the projects list URL can be a GitHub organization URL, like http://github.com/codeforamerica.
To add extra data about your projects to the CfAPI, include a civic.json
file in the top level of your repo.
Currently we accept status
and tags
as fields in the civic.json.
An example civic.json file
"status": "Production",
"tags": ["slack", "bot", "integration", "python", "flask", "glossary", "dictionary"]
This project could then be easily found by searching the CfAPI like http://codeforamerica.org/api/projects?q=production,slack,bot
The civic.json
idea comes from BetaNYC and still has an active discussion about its spec.
Once you've got your organization's GitHub projects on the API, all of your groups open GitHub Issues will be seen in the Civic Tech Issue Finder. Use the label “help wanted” to get the most exposure. More info on that project's README.
The CFAPI is built on Flask and Python. The app.py
file describes the models and routes. The run_update.py
file runs once an hour and collects all the data about the different Brigades. Both tests.py
and run_update_test.py
are automatically run by Travis-CI whenever a new commit is made. The production service lives on Heroku. Please contact us with any questions.
DATABASE_URL=[db connection string]
? My local example is postgres:///cfapi
GITHUB_TOKEN=[GitHub API token]
? Read about setting that up here: http://developer.github.com/v3/oauth/MEETUP_KEY=[Meetup API Key]
? Read about setting that up here: https://secure.meetup.com/meetup_api/key/Set these up in a local .env
file.
Set up a virtual environment
Install the required libraries
p install -r requirements.txt
tedb cfapi
on app.py createdb
The run_update.py
script will be run on Heroku once an hour and populate the database. To run locally, try:
on run_update.py
You can update just one organization if you need by using:
on run_update.py --name "Beta NYC"
For quicker update testing, use a shorter list of orgs by calling run_update.py with the --test
flag:
on run_update.py --test
`cat .env` python app.py runserver
man start
localhost:5000
in your browser to see the results://localhost:5000/api/organizations/Code-for-America
Deployment is typically on Heroku. Follow this tutorial for basic information on how to setup the project.
These must be set:
GITHUB_TOKEN
MEETUP_KEY
(if used)DATABASE_URL
will be handled by Heroku.
ku run bash
on -c 'from app import db; db.create_all()'
tedb civic_json_worker_test
on -c 'from app import db; db.create_all()'
tedb peopledbtest
peopledbtest < test/peopledbtest.pgsql
green -vvv --run-coverage
to run everything at once.
green test/updater -vvv
to test the run_update process.
green test/updater -vvv --run-coverage
to test the run_update process with coverage.
green test/integration -vvv
to test the API.
green test/integration -vvv --run-coverage
to test the API with code coverage.
The project ships with flake8 to track style, perform a flake8 check by calling
flake8 . --exclude=migrations,test --ignore=E501,E711,E712
Migrations are handled through flask-migrate
Here are some ways you can contribute:
We use the GitHub issue tracker to track bugs and features. Before submitting a bug report or feature request, check to make sure it hasn't already been submitted. You can indicate support for an existing issue by voting it up. When submitting a bug report, please include a Gist that includes a stack trace and any details that may be necessary to reproduce the bug.
Copyright (c) 2015 Code for America.