How to Set Up the Odysee API Server

Jun 8, 2024 | Blockchain

If you want to interact with the Odysee platform, the API server is your gateway. This server primarily acts as a bridge connecting the web interface with blockchain functionalities. In this guide, we’ll explore how to set up the Odysee API Server both from source and through Docker, as well as some useful tips for developers.

Required Tools

Before diving into the setup, ensure you have the following tools installed:

  • go install github.com/volatiletech/sqlboiler
  • go install github.com/volatiletech/sqlboiler/drivers/sqlboiler-psql

Running from Source

If you prefer to run the API server from the source code, follow these steps:

  1. Launch the core environment containers:

    Use the command:

    docker compose up -d

    Note: If you’re using a LBRY desktop app or a lbrynet instance, make sure to either shut it down or change the application ports.

  2. Set up the database schema (if this is your first launch):
    go run . db_migrate_up
  3. Generate an RSA key file:
    ssh-keygen -t rsa -f token_privkey.rsa -m pem
  4. Start the Odysee API server:
    go run .
  5. Clone the lbry-desktop repository:
    cd ..git clone git@github.com:lbryio/lbry-desktop.git
  6. Launch UI in the lbry-desktop repository folder:
    SDK_API_URL=http://localhost:8080 yarn dev:web

Running with Docker

If you prefer using Docker, follow these steps:

  1. Initialize and launch the containers:

    To pull and launch the SDK and Postgres images, run:

    docker compose -f docker-compose.yml -f docker-compose.app.yml up -d

    Note: Again, if you’re using a LBRY desktop app or lbrynet instance, make sure to either shut it down or change the ports.

  2. Clone the lbry-desktop repository:
    cd ..git clone git@github.com:lbryio/lbry-desktop.git
  3. Launch UI in the lbry-desktop repository folder:
    LBRY_WEB_API=http://localhost:8080 yarn dev:web
  4. Open the API endpoint:

    For the best experience, visit:

    http://localhost:9090

Development Tips

As you dive into development, keep these tips in mind:

  1. Create a schema migration.
  2. Apply schema migration using:
    go run . db_migrate_up
  3. Run make models for sqlboiler to pick up any changes.

Testing

Make sure you have the lbrynet, postgres, and postgres-collector containers running. You can initiate tests by running:

make prepare_test test

Building Docker Images

To build Docker images, ensure you have Go version 1.22 installed. Use the following commands:

make oapi
make oapi_image

Note: If your default Go version differs from 1.22, supply a different Go binary path with:

go=1.22.1 make oapi

Versioning

This project uses CalVer YY.MM.MINOR since February 2021 (previously used SemVer).

Contributing

Contributions to this project are welcome. Make sure your code builds successfully, with automated tests passing, before pushing your branch. Remember to format your code with go fmt or the build will fail.

License

This project is MIT licensed. For the complete license, see LICENSE.

Security

We take security seriously. For any issues, please reach out to security@lbry.io. If needed, our PGP key is available here.

Troubleshooting

While setting up the Odysee API server, you may encounter some challenges. Here are a few troubleshooting ideas:

  • If you experience issues with Docker, ensure you have the latest stable version installed.
  • Check the ports being used by your LBRY desktop app or lbrynet instance. You may need to change them to avoid conflicts.
  • If the API doesn’t start, make sure the previous commands completed successfully and that the environment is set up correctly.

For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox