# @autom8apps/strapi-sdk-javascript

> The new flavored version of the no longer maintained Strapi SDK for JavaScript

Latest version **0.5.9** (published 2021-10-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install @autom8apps/strapi-sdk-javascript
pnpm add @autom8apps/strapi-sdk-javascript
yarn add @autom8apps/strapi-sdk-javascript
bun add @autom8apps/strapi-sdk-javascript
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.9 |
| Published | 2021-10-14 |
| First published | 2020-09-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=12.*.* |
| Dependencies | 3 |
| Unpacked size | 39 KB |
| Known vulnerabilities | 0 (+25 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | The talented Strapi.io dev team |
| Maintainers | jwizard, theringleman |

## Links

- npm: https://www.npmjs.com/package/@autom8apps/strapi-sdk-javascript
- Repository: https://github.com/autom8-apps/strapi--javascript-sdk
- Homepage: https://github.com/autom8-apps/strapi--javascript-sdk#readme
- Issues: https://github.com/autom8-apps/strapi--javascript-sdk/issues
- npm.io page: https://npm.io/package/@autom8apps/strapi-sdk-javascript

## Dependencies (3)

- [qs](https://npm.io/package/qs.md) ^6.5.2
- [axios](https://npm.io/package/axios.md) ^0.18.0
- [js-cookie](https://npm.io/package/js-cookie.md) ^2.2.0

## Recent versions

- 0.5.9 (latest) — 2021-10-14
- 0.5.8 — 2021-10-14
- 0.5.7 — 2021-10-14
- 0.5.6 — 2021-10-14
- 0.5.5 — 2021-10-14
- 0.5.4 — 2021-10-14
- 0.5.3 — 2020-09-29
- 0.5.1 — 2020-09-29

## README

### DESCRIPTION

This is a duplicated version of the no longer maintained **[strapi javascript sdk](https://github.com/strapi/strapi-sdk-javascript)**

**USE WITH CAUTION:** I revamped the no longer supported project because I didn't want to build my own SDK and I wanted something I could use for my various personal projects. I have no intention at the moment of supporting this package for the long term. Install at your own discretion.

---

## Install

```sh
npm install @autom8apps/strapi-sdk-javascript
```

## Start now

### New instance
```js
import Strapi from '@autom8apps/strapi-sdk-javascript';

const strapi = new Strapi('http://localhost:1337');
```

### Authentications

#### Local
```js
await strapi.login('username_or_email', 's3cr3t');
```

#### [Providers](https://strapi.io/documentation/guides/authentication.html#providers)
```js
// Redirect your user to the provider's authentication page.
window.location = strapi.getProviderAuthenticationUrl('facebook');
```
Once authorized, the provider will redirects the user to your app with an access token in the URL.
```js
// Complete the authentication: (The SDK will store the access token for you)
await strapi.authenticateProvider('facebook');
```
You can now fetch private APIs
```js
const posts = await strapi.getEntries('posts');
```

### Files management

#### Browser
```js
const form = new FormData();
form.append('files', fileInputElement.files[0], 'file-name.ext');
form.append('files', fileInputElement.files[1], 'file-2-name.ext');
const files = await strapi.upload(form);
```

#### Node.js
```js
const FormData = require('form-data');
const fs = require('fs');
const form = new FormData();
form.append('files', fs.createReadStream('./file-name.ext'), 'file-name.ext');
const files = await strapi.upload(form, {
  headers: form.getHeaders()
});
```


## Functions/Methods

### `Strapi(baseURL, storeConfig, requestConfig)`
### `request(method, url, requestConfig)`
### `register(username, email, password)`
### `login(identifier, password)`
### `forgotPassword(email, url)`
### `resetPassword(code, password, passwordConfirmation)`
### `getProviderAuthenticationUrl(provider)`
### `authenticateProvider(provider, params)`
### `setToken(token, comesFromStorage)`
### `clearToken(token)`
### `getEntries(contentTypePluralized, params)`
### `getEntry(contentTypePluralized, id)`
### `getEntryCount(contentTypePluralized, params)`
### `createEntry(contentTypePluralized, data)`
### `updateEntry(contentTypePluralized, id, data)`
### `deleteEntry(contentTypePluralized, id)`
### `searchFiles(query)`
### `getFiles(params)`
### `getFile(id)`
### `upload(data)`

#### requestConfig

Custom axios request configuration. [See documentation](https://github.com/axios/axios#request-config)

## Resources

* [Documentation](https://strapi.github.io/strapi-sdk-javascript)
* [Changelog](https://github.com/strapi/strapi-sdk-javascript/blob/master/CHANGELOG.md)
* [Medium story](https://medium.com/strapi/announcing-the-strapi-javascript-sdk-ac89f140a9d1)

## Credits

* [axios](https://github.com/axios/axios)
* [typescript-starter](https://github.com/bitjson/typescript-starter)
* [The talented Strapi team, thank you so much for building this!](https://strapi.io/)

## License

MIT

---
_Source: https://npm.io/package/@autom8apps/strapi-sdk-javascript · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
