Skip to main content

py-gitea

A simple API client for Gitea > 1.24 based on the idea that passing around dictionaries and strings is disgusting and needs to be wrapped in something safe. So, the whole implementation is focused on making access and working with Organizations, Teams, Repositories and Users as pain free as possible.

Most functions should be covered by tests or should be in use (somewhere) so things should work as expected. Note that not the full Swagger-API is accessible.

Originally forked from https://github.com/m301/py-gitea.

Usage

First get a gitea object wrapping access and authentication (via an api token) for your gitea instance:

from gitea import *

gitea = Gitea(URL, TOKEN)

Operations like requesting the Gitea version or authentication user can be done directly from the gitea object:

print("Gitea Version: " + gitea.get_version())
print("API-Token belongs to user: " + gitea.get_user().username)

Adding entities like Users, Organizations, ... also is done via the gitea object.

user = gitea.create_user("Test Testson", "test@test.test", "password")

All operations on entities in gitea are then accomplished via the according wrapper objects for those entities. Each of those objects has a .request method that creates an entity according to your gitea instance

other_user = User.request(gitea, "OtherUserName")
print(other_user.username)

or can be requested from other entities.

orgs = user.get_orgs()
print(f"{user.name} is in orgarnisations {orgs}")

Note that the fields of the User, Organization,... classes are dynamically created at runtime, and thus not visible during divelopment. Refer to the Gitea-API documentation for the fields names.

Fields that can not be altered via gitea-api, are read only. After altering a field, the .commit method of the according object must be called to synchronize the changed fields with your gitea instance.

org = Organization.request(gitea, test_org)
org.description = "some new description"
org.location = "some new location"
org.commit()

An entity in gitea can be deleted by calling delete.

org.delete()

All entity objects do have methods to execute some of the requests possible though the gitea-api:

org = Organization.request(gitea, ORGNAME)
teams = org.get_teams()
for team in teams:
    repos = team.get_repos()
    for repo in repos:
        print(repo.name)

If something is missing, feel free to add it :).

Installation

Use pip install py-gitea to install.

Tests

Tests can be run with:

python3 -m pytest test_api.py

Make sure to have a gitea-instance running on http://localhost:3000, and an admin-user token at .token. The admin user must be named test, with email secondarytest@test.org.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_gitea-0.3.2.tar.gz (25.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_gitea-0.3.2-py3-none-any.whl (19.7 kB view details)

Uploaded Python 3

File details

Details for the file py_gitea-0.3.2.tar.gz.

File metadata

  • Download URL: py_gitea-0.3.2.tar.gz
  • Upload date:
  • Size: 25.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for py_gitea-0.3.2.tar.gz
Algorithm Hash digest
SHA256 6b72373b8b8028fc66a0d60731d109f54e137d42f29185d17e410aa7613c48fc
MD5 53e8d985f7a908bf7b862b259501915e
BLAKE2b-256 f58349baef72e4e7aabea132b717fa0ebec33e201b44d81d2e0177374e9a2981

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_gitea-0.3.2.tar.gz:

Publisher: publish_pypi.yml on Langenfeld/py-gitea

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file py_gitea-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: py_gitea-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 19.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for py_gitea-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bc51b0a198395619162d9e3276105c742da3fdfaf417ffcb2deb87a4bcf1b403
MD5 24f04aaaf27acc12ffb309b0ee1f7c88
BLAKE2b-256 d3aa3872899d53ae4917ac9cf6bd243d09816c2e54fdafe94dfb4c491e22cc15

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_gitea-0.3.2-py3-none-any.whl:

Publisher: publish_pypi.yml on Langenfeld/py-gitea

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.3.3

2 files

This release

0.3.2 This release

2 files

0.3.1

2 files

0.3.0

2 files

0.2.10

2 files

0.2.9

2 files

0.2.8

2 files

0.2.7

2 files

0.2.6

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.1.6

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page