Coder Social home page Coder Social logo

strapi / strapi-sdk-javascript Goto Github PK

View Code? Open in Web Editor NEW
270.0 21.0 45.0 827 KB

๐Ÿ”Œ Official JavaScript SDK for APIs built with Strapi.

Home Page: https://strapi.io

License: MIT License

TypeScript 100.00%
strapi nodejs api dashboard es6 graphql rest-api koa koa2 cms

strapi-sdk-javascript's Introduction

โš ๏ธ This package not up to date and maintained โš ๏ธ

We recommend you not to use this package. We stopped to maintained it by lack of time and also because the features provided by this SDK are the same as a good HTTP client well configured. So I suggest you use the best HTTP client for the technology you use. To configure it to target your Strapi API. Here so usefull ressources to help you:


The official Strapi SDK for JavaScript, available for browsers or Node.js backends.



Install

npm install strapi-sdk-javascript

Start now

New instance

import Strapi from 'strapi-sdk-javascript';

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

Authentications

Local

await strapi.login('username_or_email', 's3cr3t');
// 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.

// Complete the authentication: (The SDK will store the access token for you)
await strapi.authenticateProvider('facebook');

You can now fetch private APIs

const posts = await strapi.getEntries('posts');

Files management

Browser

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

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()
});

API

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

Resources

Roadmap

  • GraphQL
  • Attach/Detach entry relationship
  • Real time with Socket.io

Credits

License

MIT

strapi-sdk-javascript's People

Contributors

alexandrebodin avatar aurelsicoko avatar greenkeeper[bot] avatar jeanremy avatar lauriejim avatar lucaperret avatar pierreburgy avatar pritoj avatar rflipo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.