Getting started with the Fstop API
The Fstop API is a RESTful API that allows you to manage photography projects, clients, and bookings. The API returns JSON data and uses traditional HTTP methods to perform actions on data.
In this guide, you’ll authenticate with the API to get a JSON Web Token (JWT) so you can make calls to the API.
Before you begin
Section titled “Before you begin”To begin using the API, you need to complete two steps:
- Sign up for the Fstop API
- Get a JSON Web Token (JWT) to make API requests
Sign up for the Fstop API
Section titled “Sign up for the Fstop API”Before you can get a JWT, you need to sign up for the Fstop API. Your username and password can only consist of letters and numbers.
To sign up for the API:
-
Open a terminal and run the following command to create a new user account:
Terminal window curl -X POST http://localhost:8000/api/signup/ \-H "Content-Type: application/json" \-d '{"username": "your_username","password": "your_password"}'You’ll see a message confirming your account was created:
{"message": "Signup successful!"}
Request a JSON Web Token
Section titled “Request a JSON Web Token”After you sign up for the API, you need to request a JSON Web Token (JWT) so you can access resources. Without a JWT, you will not be able to make GET or POST requests to the Fstop API.
To request a JWT:
-
In your terminal, run the following command:
Terminal window curl -X POST http://localhost:8000/api/token/ \-H "Content-Type: application/json" \-d '{"username": "your_username","password": "your_password"}'You’ll receive an access token and a refresh token after you send your credentials:
{"access": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...","refresh": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."}
Request a refresh token
Section titled “Request a refresh token”The access token expires after 15 minutes. You can use the refresh token to request a new access token.
To request a new access token:
-
In your terminal, run the following command:
Terminal window curl -X POST http://localhost:8000/api/token/refresh/ \-H "Content-Type: application/json" \-d '{"refresh": "your_refresh_token"}'You’ll receive a new access token and a new refresh token:
{"access": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...","refresh": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."}
Next steps
Section titled “Next steps”Congratulations! You’ve successfully signed up for the API and received a JWT. You’re now ready to start making requests to the Fstop API. Check out the feature guides to learn how to create and retrieve projects, clients, and bookings.