An open API service indexing awesome lists of open source software.

https://github.com/audiusproject/api

Open source API backend for audius.co
https://github.com/audiusproject/api

audio ethereum protocol solana streaming web3

Last synced: 11 days ago
JSON representation

Open source API backend for audius.co

Awesome Lists containing this project

README

          

# Audius API Server

The API backend for the Audius mobile apps and [audius.co](https://audius.co)

[![license](https://img.shields.io/github/license/AudiusProject/api)](https://github.com/AudiusProject/api/blob/main/LICENSE) [![releases](https://img.shields.io/github/v/release/AudiusProject/api)](https://github.com/AudiusProject/api/releases/latest)

## Running

### Server

1. Create `.env` file:

```
readDbUrl='postgresql://postgres:somepassword@someip:5432/audius_discovery'
```

Regular database dumps are posted to S3, and can be pulled with

```
curl https://audius-pgdump.s3-us-west-2.amazonaws.com/discProvProduction.dump -O
pg_restore -d \
--username postgres \
--no-privileges \
--clean --if-exists --verbose -j 8 \
discProvProduction.dump
```

(more env vars and their defaults can be found in `config.go`)

2. Run `make setup` (the first time)

```
make setup
```

3. Run `make`

```
make
```

http://localhost:1323/v1/users/handle/audius

This will watch sql files + re-run `sqlc generate` + restart server when go files change.

### Tests

#### To run tests against the existing schemas

```
docker compose up -d
make test
```

#### To update schema after migration changes and run tests

```
make test-schema
make test
```

### Build

```
go build -o api main.go
```

## API diff

Tool for comparing the new API server endpoints with the legacy Discovery Node APIs

http://localhost:1323/apidiff.html

## Adminer

Tool for interacting with the postgres server

http://localhost:21301/?pgsql=db&username=postgres

## ElasticSearch

ElasticSearch is configured by the env var `elasticsearchUrl`.

Tool for interacting with search

http://localhost:1323/searchtest.html

Re-index collections from scratch:

```
go build -o api main.go
time ./api reindex
```

You can also specify specific indexes. If you change the mapping you can add `drop`:

```
go build -o api main.go
time ./api reindex drop playlists
```

### Re-index in stage or prod

If you make mapping changes, or want to re-index everything, you can do:

```
make esindexer-reindex-stage

#or

esindexer-reindex-prod
```

A deploy might disrupt this command, in which case, run it again.

See `Makefile` for more details.