0.1.12 • Published 6 months ago

one-sdk-to-rule-them-all v0.1.12

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

Lord of the Rings SDK

Installation

Get an access token from The One Api. Then npm install one-sdk-to-rule-them-all

Examples

Examples may be found in /examples/example.js

Usage

const OneSdkToRuleThemAll = require('one-sdk-to-rule-them-all');
const client = new OneSdkToRuleThemAll('API-TOKEN-HERE');

(async () =>  {
  try {
    const books = await client.getBooks();
    console.log(books);
  } catch (error) {
    console.error(error);
  }
})()

Initialization

const OneSdkToRuleThemAll = require('one-sdk-to-rule-them-all');
const client = new OneSdkToRuleThemAll('API-TOKEN-HERE');

Fetches a list of all books from the the-one-api API without any requestConfigs set.

Example Usage:

const books = await client.getBooks();

Example Return:

"docs": [
    {"_id": "5cf5805fb53e011a64671582", "name": "The Fellowship Of The Ring"},
    {"_id": "5cf58080b53e011a64671584", "name": "The Return Of The King"},
    {"_id": "5cf58077b53e011a64671583", "name": "The Two Towers"}
],
"total": 3,
"limit": 1000,
"offset": 0,
"page": 1,
"pages": 1

getBooks(requestConfigs)

Fetches a list of all books from the the-one-api API with requestConfigs set.

Example Usage:

const books = await client.getBooks({
    filtering: {
        exclude: {
            excludeKey: 'name',
            excludeValue: 'The Two Towers'
        }
    }
});

Example Return:

"docs": [
    {"_id": "5cf5805fb53e011a64671582", "name": "The Fellowship Of The Ring"},
    {"_id": "5cf58080b53e011a64671584", "name": "The Return Of The King"},
],
"total": 2,
"limit": 1000,
"offset": 0,
"page": 1,
"pages": 1

Fetches a specific book from the the-one-api API without any requestConfigs set.

Example Usage:

const books = await client.getBook('5cf5805fb53e011a64671582');

Example Return:

"docs": [
    {"_id": "5cf5805fb53e011a64671582", "name": "The Fellowship Of The Ring"},
],
"total": 1,
"limit": 1000,
"offset": 0,
"page": 1,
"pages": 1

Fetches all chapters of a specific book from the the-one-api API without any requestConfigs set.

Example Usage:

const books = await client.getBookChapters('5cf5805fb53e011a64671582');

Example Return:

"docs": [
    // ... Additional chapter objects ...
    {"_id": "6091b6d6d58360f988133ba0", "chapterName": "The Breaking of the Fellowship"},
],
"total": 22,
"limit": 1000,
"offset": 0,
"page": 1,
"pages": 1

getBookChapters(bookId, requestConfigs)

Fetches all chapters of a specific book from the the-one-api API with requestConfigs set.

Example Usage:

const books = await client.getBookChapters('5cf5805fb53e011a64671582', {
    filtering: {
        exclude: {
            excludeKey: 'chapterName',
            excludeValue: 'The Mirror of Galadriel',
        }
    }
});

Example Return:

"docs": [
    {"_id": "6091b6d6d58360f988133b9e", "chapterName": "Farewell to Lórien"},
    {"_id": "6091b6d6d58360f988133b9f", "chapterName": "The Great River"},
    {"_id": "6091b6d6d58360f988133ba0", "chapterName": "The Breaking of the Fellowship"}
],
"total": 3,
"limit": 1000,
"offset": 0,
"page": 1,
"pages": 1

getMovies()

Fetches all movies without any requestConfig set.

Example Usage:

const quotes = await client.getMovies();`

Example Return:

"docs": [
    // ... Additional quote objects ...
    {
      "_id": "5cd95395de30eff6ebccde5d",
      "name": "The Return of the King",
      "runtimeInMinutes": 201,
      "budgetInMillions": 94,
      "boxOfficeRevenueInMillions": 1120,
      "academyAwardNominations": 11,
      "academyAwardWins": 11,
      "rottenTomatoesScore": 95
    }
  ],
  "total": 8,
  "limit": 1000,
  "offset": 0,
  "page": 1,
  "pages": 1

getMovies(requestConfig)

Fetches all movies with requestConfig set.

Example Usage:

const quotes = await client.getMovies({
    sorting: {
        sortingKey: 'name',
        sortingDirection: 'desc',
    }
});`

Example Return:

"docs": [
    // ... Additional quote objects ...
    {
      "_id": "5cd95395de30eff6ebccde5a",
      "name": "The Battle of the Five Armies",
      "runtimeInMinutes": 144,
      "budgetInMillions": 250,
      "boxOfficeRevenueInMillions": 956,
      "academyAwardNominations": 1,
      "academyAwardWins": 0,
      "rottenTomatoesScore": 60
    }
  ],
  "total": 8,
  "limit": 1000,
  "offset": 0,
  "page": 1,
  "pages": 1

getMovie(movieId)

Fetches a specific movie by its ID without requestConfig set.

Example Usage:

const quotes = await client.getMovie('5cd95395de30eff6ebccde5b');`

Example Return:

"docs": [
    {
      "_id": "5cd95395de30eff6ebccde5b",
      "name": "The Two Towers",
      "runtimeInMinutes": 179,
      "budgetInMillions": 94,
      "boxOfficeRevenueInMillions": 926,
      "academyAwardNominations": 6,
      "academyAwardWins": 2,
      "rottenTomatoesScore": 96
    }
  ],
  "total": 1,
  "limit": 1000,
  "offset": 0,
  "page": 1,
  "pages": 1

getMovieQuotes(movieId)

Fetches all quotes from a specific movie by its ID without any requestConfigs set.

Example Usage:

const quotes = await client.getMovieQuotes('5cd95395de30eff6ebccde5b');`

Example Return:

"docs": [
  // ... Additional quote objects ...
  {
    "_id": "5cd96e05de30eff6ebcce84a",
    "dialog": "My dear Sam, you cannot always be torn in two...",
    "movie": "5cd95395de30eff6ebccde5d",
    "character": "5cd99d4bde30eff6ebccfc15"
  },
  // ... Additional quote objects ...  
],
"total": 100,
"limit": 100,
"offset": 0,
"page": 1,
"pages": 1

getMovieQuotes(movieId, requestConfig)

Fetches all quotes from a specific movie by its ID with requestConfig set.

Example Usage:

const quotes = await client.getMovieQuotes('5cd95395de30eff6ebccde5b', {
    filtering: {
        regexInclude: {
            regexIncludeKey: '_id',
            regexIncludeValue: /5cd96e05de30eff6ebcce84a/i,
        },
    }
});`

Example Return:

"docs": [
  {
    "_id": "5cd96e05de30eff6ebcce84a",
    "dialog": "My dear Sam, you cannot always be torn in two...",
    "movie": "5cd95395de30eff6ebccde5d",
    "character": "5cd99d4bde30eff6ebccfc15"
  }
],
"total": 1,
"limit": 100,
"offset": 0,
"page": 1,
"pages": 1

getCharacters()

Fetches all characters without any requestConfigs set.

Example Usage:

const quotes = await client.getCharacters();`

Example Return:

"docs": [
  {
    "_id": "5cd99d4bde30eff6ebccfc1f",
    "height": "1.76m / 5'9 (film)",
    "race": "Human",
    "gender": "Male",
    "birth": "TA 2925",
    "spouse": "Unnamed wife",
    "death": "TA 3007",
    "realm": "Dale",
    "hair": "Brown (film)",
    "name": "Bain",
    "wikiUrl": "http://lotr.wikia.com//wiki/Bain"
  },
  {
    "_id": "5cd99d4bde30eff6ebccfc20",
    "height": "",
    "race": "Human",
    "gender": "",
    "birth": "",
    "spouse": "",
    "death": "",
    "realm": "",
    "hair": "",
    "name": "Baranor (Gondor)",
    "wikiUrl": "http://lotr.wikia.com//wiki/Baranor_(Gondor)"
  },
  // ... Additional quote objects ...  
],
"total": 100,
"limit": 1000,
"offset": 0,
"page": 1,
"pages": 1

getCharacters()

Fetches all characters with requestConfigs set.

Example Usage:

const quotes = await client.getCharacters({
    filtering: {
        include: {
            includeKey: 'name',
            includeValue: 'Bain'
        },
    }
});`

Example Return:

"docs": [
  {
    "_id": "5cd99d4bde30eff6ebccfc1f",
    "height": "1.76m / 5'9 (film)",
    "race": "Human",
    "gender": "Male",
    "birth": "TA 2925",
    "spouse": "Unnamed wife",
    "death": "TA 3007",
    "realm": "Dale",
    "hair": "Brown (film)",
    "name": "Bain",
    "wikiUrl": "http://lotr.wikia.com//wiki/Bain"
  },
],
"total": 1,
"limit": 1000,
"offset": 0,
"page": 1,
"pages": 1

getCharacter(characterId)

Fetches a specific character without any requestConfigs set.

Example Usage:

const quotes = await client.getCharacters('5cd99d4bde30eff6ebccfc1f');`

Example Return:

"docs": [
  {
    "_id": "5cd99d4bde30eff6ebccfc1f",
    "height": "1.76m / 5'9 (film)",
    "race": "Human",
    "gender": "Male",
    "birth": "TA 2925",
    "spouse": "Unnamed wife",
    "death": "TA 3007",
    "realm": "Dale",
    "hair": "Brown (film)",
    "name": "Bain",
    "wikiUrl": "http://lotr.wikia.com//wiki/Bain"
  },
],
"total": 1,
"limit": 1000,
"offset": 0,
"page": 1,
"pages": 1

getCharacterQuotes(characterId)

Fetches all quotes for a specific characters without any requestConfigs set.

Example Usage:

const quotes = await client.getCharacterQuotes('5cd99d4bde30eff6ebccfc15');`

Example Return:

"docs": [
  {
    "_id": "5cd96e05de30eff6ebcce84a",
    "dialog": "My dear Sam, you cannot always be torn in two. You will have to be one and whole for many years. You have so much to enjoy and to be and to do. Your part in the story will go on.",
    "movie": "5cd95395de30eff6ebccde5d",
    "character": "5cd99d4bde30eff6ebccfc15",
    "id": "5cd96e05de30eff6ebcce84a"
  },
  // ... Additional quote objects ...  
],
"total": 67,
"limit": 1000,
"offset": 0,
"page": 1,
"pages": 1

getQuotes()

Fetches a list of all the quotes from the API.

Example Usage:

const quotes = await client.getQuotes();

Example Return:

"docs": [
  // ... Additional quote objects ...
  {
    "_id": "5cd96e05de30eff6ebcce84c",
    "dialog": "I didn't think it would end this way.",
    "movie": "5cd95395de30eff6ebccde5d",
    "character": "5cd99d4bde30eff6ebccfe2e"
  },
  // ... Additional quote objects ...
]
"total": 100,
"limit": 100,
"offset": 0,
"page": 1,
"pages": 1

getQuote(quoteId)

Fetches data for a specific quote by its ID.

Example Usage:

const quote = await client.getQuote('5cd96e05de30eff6ebcce84c');

Example Return:

"docs": [
    {
    "_id": "5cd96e05de30eff6ebcce84c",
    "dialog": "I didn't think it would end this way.",
    "movie": "5cd95395de30eff6ebccde5d",
    "character": "5cd99d4bde30eff6ebccfe2e"
    }
],
"total": 1,
"limit": 100,
"offset": 0,
"page": 1,
"pages": 1

getChapters()

Fetches a list of all the chapters from every book in the API.

Example Usage:

const quotes = await client.getChapters();

Example Return:

"docs": [
  // ... Additional chapter objects ...
  {
    "_id": "5cd96e05de30eff6ebcce84c",
    "dialog": "I didn't think it would end this way.",
    "movie": "5cd95395de30eff6ebccde5d",
    "character": "5cd99d4bde30eff6ebccfe2e"
  },
  // ... Additional chapter objects ...
]
"total": 100,
"limit": 100,
"offset": 0,
"page": 1,
"pages": 1

getChapter(chapterId)

Fetches data for a specific quote by its ID.

Example Usage:

const quote = await client.getChapter('5cd96e05de30eff6ebcce84c');

Example Return:

"docs": [
    {
    "_id": "5cd96e05de30eff6ebcce84c",
    "dialog": "I didn't think it would end this way.",
    "movie": "5cd95395de30eff6ebccde5d",
    "character": "5cd99d4bde30eff6ebccfe2e"
    }
],
"total": 1,
"limit": 100,
"offset": 0,
"page": 1,
"pages": 1
0.1.12

6 months ago

0.1.11

6 months ago

0.1.10

6 months ago

0.1.9

6 months ago

0.1.8

6 months ago

0.1.7

6 months ago

0.1.6

6 months ago

0.1.5

6 months ago

0.1.4

6 months ago

0.1.3

6 months ago

0.1.2

6 months ago

0.1.1

6 months ago

0.1.0

6 months ago