@mikazuki/pixela
TypeScript icon, indicating that this package has built-in type declarations

0.2.1 • Public • Published

Pixela.js

GitHub npm (scoped) FOSSA Status

Pixela API for JavaScript written in TypeScript.

Install

yarn add @mikazuki/pixela

CDN : UNPKG | jsDelivr

How to use

In Browser

<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@mikazuki/pixela"></script>
<script>
  const client = new window.Pixela("YOUR_NAME", "YOUR_TOKEN");
  client
    .incrementPixel("graph_id")
    .then(() => {
      console.log("Increment Pixel!");
    })
    .catch(() => {
      console.log("Error!");
    });
</script>

In Node.js

import Pixela from "@mikazuki/pixela";

const graphId = "tweets";

const client = new Pixela("username", "token");

// if you don't have an account, create a new account
await client.createUser({ agreeTermsOfService: true, notMinor: true });

// create new graph
await client.createGraph({ id: graphId, name: "Tweets Per Day", unit: "tweets", ...});

// increment today's pixel
await client.incrementPixel(graphId);

If you want to see real-world example?
Please check-out Knockru/Crouton repository!

License

FOSSA Status

Readme

Keywords

none

Package Sidebar

Install

npm i @mikazuki/pixela

Weekly Downloads

1

Version

0.2.1

License

MIT

Unpacked Size

54.2 kB

Total Files

11

Last publish

Collaborators

  • mikazuki