pawn-api

module
v0.15.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2026 License: MIT

README

pawn-api

pawn-api is PawnKit's versioned database of SA-MP and open.mp natives, callbacks, constants, and tags. It includes a Go package for querying the data and a CLI for maintaining it.

Tools use this data to answer questions such as whether SetPlayerPos exists for a profile, which parameters it accepts, and whether it is deprecated.

Status

This is a pre-1.0 dataset, not a complete copy of omp-stdlib. It currently has 387 reviewed entries: 268 natives, 45 callbacks, one function, 61 constants, and 12 tags.

Install

go get github.com/pawnkit/pawn-api

Requires Go 1.26 or later.

go install github.com/pawnkit/pawn-api/cmd/pawnapi@latest

Quick start

package main

import (
	"fmt"

	"github.com/pawnkit/pawn-api/pawnapi"
)

func main() {
	ix, err := pawnapi.Load()
	if err != nil {
		panic(err)
	}

	e, ok := ix.ByID("native:SetPlayerPos")
	fmt.Println(ok, e.Name, e.Signature.ReturnTag)

	for _, cb := range ix.ByKind(pawnapi.KindCallback) {
		fmt.Println(cb.Name)
	}

	for _, e := range ix.ByProfile("samp-037") {
		fmt.Println(e.ID, "is available under samp-037")
	}
}

Maintain the dataset

pawnapi validate
pawnapi generate
pawnapi generate --check
pawnapi coverage pawnapi/data/pawn-api.full.json /path/to/omp-stdlib/omp_*.inc

generate --check is intended for CI. It fails when the embedded and interchange files do not match the source data. coverage compares a dataset with declarations extracted from one or more includes. It exits with status 1 when declarations are missing.

Current coverage

Kind Count Examples
native 304 SetPlayerPos, Create3DTextLabel, HTTP
callback 45 OnPlayerConnect, OnPlayerEnterGangZone, OnPlayerClickGangZone
function 1 SetTeamCount
constant 63 INVALID_3DTEXT_ID, HTTP_GET, HTTP_ERROR_BAD_HOST
tag 14 Float, Text3D, HTTP_METHOD, HTTP_ERROR

Each entry records its upstream repository, file, commit, licence, and confidence. docs/licence-report.md explains how that provenance is collected.

Limits

  • Coverage is concentrated on player and vehicle functions and core lifecycle callbacks. Many omp-stdlib include files are not imported yet.
  • At the pinned omp-stdlib commit, 352 of the 1,061 declarations extracted from omp_*.inc have matching entries. The dataset also contains 75 core constants and tags represented differently in the includes.
  • pawnapi snapshot accepts full-model JSON or a Pawn include. Include import covers natives, forwards/callbacks, named tags, and literal defines.
  • SA-MP availability is reviewed against a pinned 0.3.7 include source.
  • Schema version 1 does not contain every field used by the Go model. The gap is listed in docs/compatibility.md.

Third-party library APIs are not bundled here. PawnKit reads them from the project's installed includes, so completion and diagnostics match the version the project actually uses.

Directories

Path Synopsis
cmd
pawnapi command
Command pawnapi maintains and compares Pawn API datasets.
Command pawnapi maintains and compares Pawn API datasets.
Package importer extracts API declarations from Pawn includes.
Package importer extracts API declarations from Pawn includes.
internal
generator
Package generator builds pawn-api datasets from reviewed JSON sources.
Package generator builds pawn-api datasets from reviewed JSON sources.
schema
Package schema validates pawn-api interchange documents.
Package schema validates pawn-api interchange documents.
Package pawnapi provides machine-readable SA-MP and open.mp API data.
Package pawnapi provides machine-readable SA-MP and open.mp API data.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL