If you need programmatic access to the Surge platform, look no further! You can use the Surge API to manage all aspects of your labeling project. Our open-source Python SDK provides convenient access to our API, with functions for creating new projects, running tasks, and much more.
In this blog post, we'll walk through the setup of a sample project from start to finish using our Python SDK.
If you haven't already, sign up for an account on Surge. Once you are logged in, go to your Profile page and copy your API key. This will be used to authenticate your API requests.
Next, use pip to install our Python package:
pip install --upgrade surge-api
Your API key carries many privileges, so be sure to keep it secure! Do not share it in publicly accessible areas such as GitHub, client-side code, and so forth.
To use your API key, assign it to surge.api_key. The Python SDK will then automatically send this key to authenticate each request.
Alternatively, you can set your API key as an environment variable.
export SURGE_API_KEY=YOUR-API-KEY
Now, it's time to create a new labeling project. Let's make one to gather information about movie reviews.
Each project should have a list of questions to be completed by the labeling workforce. Surge supports a wide range of questions including multiple choice, free response, text tagging, bounding boxes, etc.
To create new questions, instantiate the desired Question objects. In this project, we will ask labelers to tag named entities in the movie review (text tagging), determine its sentiment (multiple choice), and write their very own review (free response).
Notice that the text associated with the text tagging question is {{review}}, which is a handlebars expression. The actual movie review will automatically replace this placeholder once we import data, which we'll do in the upcoming task creation step.
Once the questions have been created, simply pass them into the method surge.Project.create():