Getting Started
Spare authenticates your API requests using your account's API keys. If you do not include your key when making an API request, or use one that is incorrect or outdated, Spare returns an error.
By now you should have received administrator login credentials for Spare Platform (https://platform.sparelabs.com). Access Spare Platform will enable you to set up your test organization, manage your testing environment, and test your application using the various service types within the Spare Platform.
Before you can implement server-side authentication, you will need to create API Keys for your applications. API Keys can be generated in the Administrative Panel under Organization Settings.
<aside>
⚠️ Do not expose your Spare API key to client side applications.
</aside>
All API requests must be made over HTTPS. Calls made over plain HTTP will fail. API requests without authentication will also fail.
Authentication to the API from the server side is performed via your Secret API Key.
To authenticate use header: Authorization: Bearer <secret-api-key>
Your API Keys are always available in your organization. If you have any questions, consult your Launch Manager, Partner Success Manager, or contact us!
Setting up a Testing Environment
Before ride requests can be made using the Rides API, you will need to set up a testing environment. Take the following steps to quickly set up a testing environment:
- Create Service - Create a service under the services pane.
- Ensure that valid Time Rules are set for this service. Time Rules specify the valid times at which a rider may book a trip for this service.
- If the service is stop-to-stop you will need to create stops and add them to the service.
- Ensure there is a valid Fleet associated with a service. There are types of fleets you can select from: Auto Accept and Accept Reject. Auto Accept fleets require there to be duties pre-scheduled for estimates to succeed and requests are automatically matched to drivers as they are sent to the system. Accept Reject fleets assume that there will be undedicated drivers online eventually to accept the trip. In order to get realistic estimates with an Accept Reject fleet, you will need to first go online in the Driver App.
- Create Driver - You can create one in the drivers pane. If you would like this driver to be able to drive unscheduled using an Accept Reject fleet, then make sure you assign this fleet to the driver. Once the driver is created, they will be sent an email. Confirm this email and set a password online. Then you may login with the driver account in the Spare Driver app.
- Create Vehicle - You can create a vehicle in the vehicles pane.
- Create Duty - Duties are essentially driver shifts. Spare uses duties to understand the available vehicle supply in the system. Duties are created through the duty pane and must be assigned to a service, driver, and vehicle. If you would like to do tests without using the driver app, you can create a duty that starts in the past and ends some time in the future. Spare will match against this duty. To complete passenger trips and see live vehicle tracking, log in to the Spare Driver app with your driver’s credentials and start the duty.
- NOTE: To book trips in the system at a given time against Auto Accept fleets, it is essential that at least one duty be scheduled at that time. Ideally, the duty should start before the requested trip time and end after. This is to give the driver plenty of time to arrive at the rider’s pickup location, drive to the dropoff location, then drive to the duty end location before the duty end time.