strava-api-lib
v1.0.0
Published
A wrapper for the Strava API
Downloads
17
Readme
Strava API Library and Test Application
This project consists of two main parts:
- A JavaScript library wrapper for the Strava API (
strava-api-lib
) - A React test application that demonstrates the usage of the library (
strava-test-app
)
Strava API Library
The strava-api-lib
is a TypeScript library that provides a simple interface to interact with the Strava API. It handles authentication and provides methods to fetch athlete data and activities.
Installation
To install the library in your project:
bash npm install ../path/to/strava-api-lib
Usage
typescript
import StravaAPI from 'strava-api-lib';
const stravaApi = new StravaAPI({
clientId: 'YOUR_CLIENT_ID',
clientSecret: 'YOUR_CLIENT_SECRET',
redirectUri: 'YOUR_REDIRECT_URI',
});
// Authenticate
await stravaApi.authenticate(code);
// Get athlete data
const athleteData = await stravaApi.getAthlete();
// Get activities
const activities = await stravaApi.getActivities();
React Test Application
The strava-test-app
is a React application that demonstrates how to use the Strava API library. It allows users to log in with their Strava account and view their recent activities.
Setup
- Navigate to the
strava-test-app
directory - Install dependencies:
npm install
- Create a
.env
file based on the.env.example
(see Environment Variables section) - Start the development server:
npm start
Environment Variables
Create a .env
file in the strava-test-app
directory with the following content:
REACT_APP_STRAVA_CLIENT_ID=YOUR_CLIENT_ID
REACT_APP_STRAVA_CLIENT_SECRET=YOUR_CLIENT_SECRET
REACT_APP_STRAVA_REDIRECT_URI=YOUR_REDIRECT_URI
Replace YOUR_CLIENT_ID
, YOUR_CLIENT_SECRET
, and YOUR_REDIRECT_URI
with your actual Strava API credentials.
Project Structure
strava-api-lib/
: Contains the library codestrava-test-app/
: Contains the test application code
Development
To make changes to the library:
Edit the files in
strava-api-lib/src
Rebuild the library:
cd strava-api-lib npm run build
Reinstall the library in the test app:
cd ../strava-test-app npm install ../path/to/strava-api-lib
Start the test app:
npm start
License
This project is licensed under the MIT License. See the LICENSE
file for more details.