Nuclear Pumpkin Mocha


    0.0.3 • Public • Published

    StarWars API Capture and Local Serve


    A library to capture all data from Star Wars API ( and serve it locally.



    I made this library to use the Star Wars API in my learning projects without having to deal with the official api rate limit.

    All the data is captured and stored in a JSON file and then served with the JSON Server library.

    The official url's from the official api are replaced with the localhost:port syntax to make all the navigation between links local.

    The standard folder where the resulting json is stored is db, the default filename is swapi.json and the default serve port is 3000.


    To use this library you must have NodeJS installed in your machine.


    To install the library use npm:

    npm install @n0n3br/starwars-api-capture-serve

    How to use

    Create a folder to host your project

    mkdir my-project

    Run the npm init command

    cd my-project
    npm init -y

    Install the library

    npm i @n0n3br/starwars-api-capture-serve

    create a index.mjs file and write your script

    import fs from "fs";
    import path from "path";
    import { capture, serve } from "@n0n3br/starwars-api-capture-serve";
    const dbFolder = "db";
    const dbFile = "swapi.json";
    const port = 3000;
    // optional - check if the database file already exists
    // you can always capture a new database before serving, but you may have trouble wth the rate limit
    const dbPath = path.resolve(".", dbFolder, dbFile);
    if (!fs.existsSync(dbPath)) {
      // Capture function parameters are optional. If not informed, 'db' and 'swapi.json' values will be used
      await capture(dbFolder, dbFile);
    // serve the resulting data
    // Serve function parameters are optional. If not informed 'db', 'swapi.json' and 3000 values will be used
    serve(dbFolder, dbFile, port);

    An usage example can also be found in the example folder



    npm i @n0n3br/starwars-api-capture-serve

    DownloadsWeekly Downloads






    Unpacked Size

    6.33 kB

    Total Files


    Last publish


    • n0n3br