Client Setup
Authentication and Making API Calls
All our requests use POST
. This is how a simple client can be made.
const baseUrl = "https://api.wattshift.com/v1";
const options = {
method: "POST",
headers: {
"x-ws-api-key": "<your api key here>",
},
};
const wattshiftApiCall = async (
path: `/${string}`,
body?: Record<string, any>
) => {
const res = await fetch(`${url}${path}`, {
...options,
body: JSON.stringify(body ?? {}),
});
return res.json();
};
Example API Call
await wattShiftApiCall(`/homes/${user.wsHomeId}/update`, {
name: "updated home name",
});