MCPcopy Index your code
hub / github.com/Chatterino/api

github.com/Chatterino/api @v4.0.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v4.0.0 ↗ · + Follow
619 symbols 2,702 edges 198 files 79 documented · 13%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Build status codecov

API

Go web service that serves as a cache to APIs that each Chatterino client could use.

Routes

Resolve URL

link_resolver/:url
Resolves a url into a preview tooltip.
Route content type: application/json
Route HTTP Status Code is almost always 200 as long as we were able to generate information about the URL, even if the API we call returns 404 or 500.
If the given URL is not a valid url, the Route HTTP status code will be 400.

Examples

url parameter: https://example.com/page

{
  "status": 200,                                               // status code returned or inferred from the page
  "thumbnail": "http://api.url/thumbnail/web.com%2Fimage.png", // proxied thumbnail url if there's an image
  "message": "",                                               // used to forward errors in case the website e.g. couldn't load
  "tooltip": "

tooltip

",                             // HTML tooltip used in Chatterino
  "link": "http://example.com/longer-page"                     // final url, after any redirects
}

url parameter: https://example.com/error

{
  "status": 404,
  "message": "Page not found"
}

API Uptime

health/uptime
Returns API service's uptime. Example response:

928h2m53.795354922s

API Memory usage

health/memory
Returns information about memory usage. Example response:

Alloc=505 MiB, TotalAlloc=17418866 MiB, Sys=3070 MiB, NumGC=111245

API Uptime and memory usage

health/combined
Returns both uptime and information about memory usage. Example response:

Uptime: 928h5m7.937821282s - Memory: Alloc=510 MiB, TotalAlloc=17419213 MiB, Sys=3070 MiB, NumGC=111246

Using your self-hosted version

If you host your own version of this API, you can modify which url Chatterino2 uses to resolve links and to resolve twitch emote sets.
Change link resolver
Change Twitch emote resolver
How to build and host
Running in Docker

Extension points exported contracts — how you extend this code

Loader (Interface)
(no doc) [19 implementers]
pkg/cache/cache.go
Resolver (Interface)
(no doc) [18 implementers]
pkg/resolver/resolver.go
ContentTypeResolver (Interface)
(no doc) [18 implementers]
internal/resolvers/default/model.go
Logger (Interface)
Logger defines the smallest interface we use of go-uber/zap's sugared logger Defining this interface makes it easier for [1 …
internal/logger/logger.go
Pool (Interface)
(no doc) [2 implementers]
internal/db/pool.go
MigrationFunction (FuncType)
(no doc)
internal/migration/run.go
Cache (Interface)
(no doc) [2 implementers]
pkg/cache/cache.go
InnerLoader (Interface)
(no doc) [19 implementers]
pkg/resolver/response_marshaller.go

Core symbols most depended-on inside this repo

MustParseURL
called by 207
pkg/utils/url.go
Run
called by 180
internal/resolvers/default/model.go
Get
called by 62
pkg/cache/cache.go
Errorw
called by 47
internal/logger/logger.go
FromContext
called by 47
internal/logger/context.go
Write
called by 41
pkg/resolver/write_limiter.go
OnContext
called by 36
internal/logger/context.go
NewTest
called by 35
internal/logger/test.go

Shape

Function 266
Method 187
Struct 147
Interface 11
TypeAlias 7
FuncType 1

Languages

Go100%

Modules by API surface

pkg/cache/db.go22 symbols
internal/mocks/mock_dbPool.go16 symbols
internal/resolvers/twitter/tweet_loader.go15 symbols
pkg/cache/cache.go14 symbols
internal/mocks/mock_TwitchAPIClient.go10 symbols
pkg/cache/memory.go9 symbols
internal/resolvers/livestreamfails/clip_loader.go9 symbols
internal/logger/noop.go9 symbols
internal/logger/logger.go9 symbols
pkg/resolver/static_responses.go8 symbols
pkg/humanize/date.go8 symbols
internal/resolvers/twitter/user_loader.go8 symbols

For agents

$ claude mcp add api \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact