Skip to content

SpigetAPI Class

VeguiDev edited this page Sep 16, 2022 · 3 revisions

Table of contents:

Constructor

Parameters

agent_name: Is the name of User Agent used to request API.

Example

const api = new SpigetAPI("example");

API Instance

It is an instance of the SpigetAPI class that contains all the methods needed to interact with the spiget Rest API.

Methods

getAuthors

This method request a list of authors.

Parameters

options (optional): Its a Basic Paginated Request

Example

Request
const auhors = await api.getAuthors();
Response
[
    {
        "id":1,
        "name":"Author Example",
        "icon": {
            "data":"base64string",
            "url":"http://url/to/the/image",
            "hash":"sadsfsfsf",
            "info":"161615616516"
        }
    }
]

getAuthor

This method request an author.

Parameters

id: It is an author id number.

Example

Request
const auhor = await api.getAuthor(1);
Response
{
    "id":1,
    "name":"Author Example",
    "icon": {
        "data":"base64string",
        "url":"http://url/to/the/image",
        "hash":"sadsfsfsf",
        "info":"161615616516"
    }
}

getCategories

This method request a list of categories.

Parameters

options (optional): Its a Basic Paginated Request

Example

Request
const categories = await api.getCategories();
Response
[
    {
        "id":1,
        "title":"Example Category"
    }
]

getCategory

This method request a category.

Parameters

id: Its an category id number.

Example

Request
const category = await api.getCategory(1);
Response
{
    "id":1,
    "title":"Example Category"
}

getResources

This method request a list of resources that you can filter by what's newest, whether it's free or not, and what version the resource is for.

Parameters

options (optional): Its a Resource Request

Example

Request
const resources = await api.getResources();
Response
[
    {
    "id": 0,
    "name": "string",
    "tag": "string",
    "contributors": "string",
    "likes": 0,
    "file": {
      "type": "string",
      "size": 0,
      "sizeUnit": "string",
      "url": "string",
      "externalUrl": "string"
    },
    "testedVersions": [
      "string"
    ],
    "links": {},
    "rating": {
      "count": 0,
      "average": 0
    },
    "releaseDate": 0,
    "updateDate": 0,
    "downloads": 0,
    "external": true,
    "icon": {
      "url": "string",
      "data": "string"
    },
    "premium": true,
    "price": 0,
    "currency": "string",
    "author": {
      "id": 0
    },
    "category": {
      "id": 0
    },
    "version": {
      "id": 0,
      "uuid": "string"
    },
    "reviews": [
      {
        "id": 0
      }
    ],
    "versions": [
      {
        "id": 0
      }
    ],
    "updates": [
      {
        "id": 0
      }
    ],
    "sourceCodeLink": "string",
    "donationLink": "string"
  }
]

getResource

This method request a resource.

Parameters

id: Its an resource id number.

Example

Request
const resource = await api.getResource(0);
Response
{
  "id": 0,
  "name": "string",
  "tag": "string",
  "contributors": "string",
  "likes": 0,
  "file": {
    "type": "string",
    "size": 0,
    "sizeUnit": "string",
    "url": "string",
    "externalUrl": "string"
  },
  "testedVersions": [
    "string"
  ],
  "links": {},
  "rating": {
    "count": 0,
    "average": 0
  },
  "releaseDate": 0,
  "updateDate": 0,
  "downloads": 0,
  "external": true,
  "icon": {
    "url": "string",
    "data": "string"
  },
   "premium": true,
  "price": 0,
  "currency": "string",
  "author": {
   "id": 0
  },
  "category": {
    "id": 0
  },
  "version": {
    "id": 0,
    "uuid": "string"
  },
  "reviews": [
    {
      "id": 0
    }
  ],
  "versions": [
    {
      "id": 0
    }
  ],
  "updates": [
    {
      "id": 0
    }
  ],
  "sourceCodeLink": "string",
  "donationLink": "string"
}

search

This method its used to search in SpigetAPI.

Parameters

entity: Must be author or resource. options: Is a Search Request Config

Example

Request
const search = await api.search("author", {
    query: "luck",
    field: "name"
});
Response
{
  "id": 0,
  "name": "string",
  "icon": {
    "url":"string",
    "data": "base64enconded",
    "hash": "4sdafasfas",
    "info": "614561654"
  }
}

Clone this wiki locally