Want to skip ahead? Choose the endpoint you want to use:
The JSONP API is a simple way to embed ControlShift petition content in external sites. It's intended for use by a front-end developer to show petitions on other pages outside of the platform.
For a live example of the JSON endpoint available, please see our developer site: developers.controlshiftlabs.com.
The following endpoints are available.
List featured campaigns:
List petitions in a category:
List petitions in an effort:
A single petition:
Search for closest petition in an effort:
This JSON endpoint allows you to reproduce the 'search for the nearest petition in an effort' interface. Use this endpoint to build a place for users to enter their location. Once they've searched for a location, we'll return the nearest petition. Note that the returned data will be in a JSON format.
The following gist shows example code for a lookup page using the endpoint.
All of the endpoints can be consumed as jsonp instead of json by adding callback or variable parameters to the URLs.
The URL slugs through the API are the same as those that are used through the web to represent specific petitions or categories. Many front-end libraries including jQuery make it easy to consume jsonp endpoints.
Current User / Signed in status
We provide a specialized jsonp endpoint to return information about the currently signed in user. Customers can use this endpoint to power features where information about the current user's petitions, sign in status, and other information about their account is displayed on external sites. Some examples of the sorts of functionality that this could be used to provide include:
- Conditionally show either a login link for unauthenticated users or a link to the user's my account page in the header of external pages.
- Show information about a user's campaigns when someone visits an external site, or a prompt to start a campaign if the currently signed in user has none.
- Show a direct link to a user's local group from an external site rather than linking to a generic search for your group page.
curl --referer http://localhost/ http://demo.controlshiftlabs.com/api/graph/me.json
should return a json blob indicating that the user is not signed in if localhost is whitelisted. Otherwise you'll get a not whitelisted error.
For authenticated users we currently return their first and last names, email addresses, and lists of petitions they've created, events they've created and local groups they are a member of.
Check our our developer site: developers.controlshiftlabs.com