Orion-NAIS
Table of Contents
About The Project
Orion-NAIS is a client to work with the NAIS API. It helps with authentication and provides a simple interface to work with the API.
When working with the API you need to have a valid token. The token is valid for a set period of time. The client will automatically refresh the token when it expires.
Why the name Orion?
The NAIS Api is provided through BarentsWatch. BarentsWatch is a Norwegian information portal that provides overview of activity and knowledge in coastal and sea areas. The Norwegian movie "Orion's Belt" from 1985 is an action movie set in the Barents region. About three men, a bulldozer, a Russian helicopter and a ship. Thus the name Orion.
Installation
Requires Python 3.10 or later.
pip install orion-nais
or using pipenv:
pipenv install orion-nais
or using uv:
uv add orion-nais
Usage
To install the package in your project run
uv add orion-nais
then add an .env file to your project with the following variables:
CLIENT_ID=
CLIENT_SECRET=
If you don't have a client id and secret you can get one from your BarentsWatch account.
Then you can use the client like this:
from orion import Orion
orion = Orion()
# Get the last 24 hours of AIS data for a ship with MMSI XXXXXXXXXX
ais = orion.get_ais_last_24H(SHIP_MMSI)
# Convert the AIS data to a line
line = orion.ais_to_line(ais)
Local development
Requirements
- pyenv - manage python versions
- uv - manage Python dependencies and packaging
To install on mac you can use homebrew:
brew upgrade
brew install pyenv uv
To install dependencies for local development:
uv sync
Makefile commands
make lint- lint the code with ruff. Mypy will check for correct typing.
make format- format the code and sort imports with ruff.
make test- run the tests in the tests folder.
make bump-patch- bump the patch version of the package. Example: 0.1.0 -> 0.1.1
make bump-minor- bump the minor version of the package. Example: 0.1.0 -> 0.2.0
make bump-major- bump the major version of the package. Example: 0.1.0 -> 1.0.0
make release- publish the package to pypi. You need to have an account and be logged in to pypi.
Structure
.
├── .bumpversion.cfg
├── .editorconfig
├── .gitignore
├── Makefile
├── README.md
├── orion
│ ├── client.py
│ ├── mmsi.py
│ ├── types
│ │ └── ais.py
│ ├── urls.py
│ ├── utils
│ │ └── get_data.py
│ └── vessel_codes.py
├── pyproject.toml
├── uv.lock
└── tests
├── make_mock_data.py
├── mocks
└── test_orion.py
.bumpversion.cfg- Configuration file for bumpversion.
.editorconfig- Configuration file for editorconfig.
.gitignore- Configuration file for git.
pyproject.toml- Configuration file for packaging, uv, ruff and mypy.
uv.lock- Lock file for uv.
Makefile- Makefile for the project. Here you can find commands for linting and formatting.
README.md- This file.
orion- The source code for the package.
client.py- The client class.
mmsi.py- A dataclass for handling MMSI numbers and MID-codes (jurisdiction).
types- A folder for types.
ais.py- A class for handling AIS messages.
urls.py- A file with urls for the API.
utils- A folder for utility functions.
get_data.py- A function for getting data from other sources. Not used by the Orion client. Contains code for getting data from the Norwegian Petroleum Directorate.
vessel_codes.py- A dataclass for looking up vessel codes.
tests- Tests for the package.
Contributing
Do you have write permissions to the repo? Then you can clone this project to a folder on your computer.
git clone https://github.com/BergensTidende/orion-nais.git
If not do the following:
- Create a personal fork of the project on Github.
- Clone the fork on your local machine. Your remote repo on Github is called
origin. - Add the original repository as a remote called
upstream. - If you created your fork a while ago be sure to pull upstream changes into your local repository.
This will clone the repo into orion-nais.
Create a branch for your changes
git checkout -b name-of-branch
Make your changes, rememeber to commit. And always write your commit messages in the present tense. Your commit message should describe what the commit, when applied, does to the code – not what you did to the code.
If you're working on a clone push the branch to github and make PR.
If your're working a fork:
- Squash your commits into a single commit with git's interactive rebase. Create a new branch if necessary.
- Push your branch to your fork on Github, the remote
origin. - From your fork open a pull request in the correct branch. Target the project's
developbranch if there is one, else go formaster. - If the maintainer requests further changes just push them to your branch. The PR will be updated automatically.
- Once the pull request is approved and merged you can pull the changes from
upstreamto your local repo and delete your extra branch(es).
Contact
Bord4 - bord4@bt.no
Metadata
Release files for orion-nais 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| orion_nais-0.2.2.tar.gz | 1.3 MB | Without provenance | Details for orion_nais-0.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| orion_nais-0.2.2-py3-none-any.whl | Python 3 | none | any | Details for orion_nais-0.2.2-py3-none-any.whl |
Total release size: 1.3 MB
Release files / orion_nais-0.2.2.tar.gz
| Download URL | orion_nais-0.2.2.tar.gz |
|---|---|
| Size | 1.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bdc56c09e2f4e075e0bc0f38e8e3cdddede4c6f1aaa89618b539ccb3c5ecb03d
|
|
BLAKE2b-256 checksum How to use checksums |
2ce41d0f57dca1410ecd5e1afaf5aefae120fda85d63228921426b54937b6276
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / orion_nais-0.2.2-py3-none-any.whl
| Download URL | orion_nais-0.2.2-py3-none-any.whl |
|---|---|
| Size | 21.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c6aa60c2eba6276ec25da0b3f791b871d9f22ac834920198b45807d1c328de8b
|
|
BLAKE2b-256 checksum How to use checksums |
cd734719bc07522ecf097d09eb38e23aa3de982acbd842ee4d1386e24885f1d5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for orion-nais 0.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.