• Stars
    star
    9
  • Rank 1,939,727 (Top 39 %)
  • Language
    Python
  • License
    MIT License
  • Created about 7 years ago
  • Updated about 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Custom API-client based on any existing API from one configuration file.

acg

Make own API client for particular API interface/server with only one configuration file. Then use it in development. For further details look down.

Release Python3 Python3 Python3

Gettings started

What is acg?

ACG allows you to create you API client (wrapper around some API) and use it in Python code in few minutes after install.

For example, you have some back-end server called Google API with address https://google.com/api/v1 and one front-end server, that grab data from back-end server or only push data to it.

Next task: you want to work with user subject, you do it with https://google.com/api/v1/user API url.

Some API endpoints:

  • get user: request to https://google.com/api/v1/user with method get and param id.
  • create user: request to https://google.com/api/v1/user with method post and params id, name, surname.
  • create user castle: request to https://google.com/api/v1/user/castle with method post and params id, castle.

Without ACG:

import requests 


create_jon_snow_user = requests.post('https://google.com/api/v1/user', params={
    'id': 7,
    'name': 'Jon',
    'surname': Snow,
})

get_jon_snow_user = requests.get('https://google.com/api/v1/user', params={'id': 7})

create_jon_snow_castle = requests.post('https://google.com/api/v1/user/castle', params={
    'id': 7,
    'castle': 'Winterfell',
})

Using ACG:

from google_api import google_api_client


create_jon_snow_user = google_api_client.user.create({
    'id': 7,
    'name': 'Jon',
    'surname': Snow
})

get_jon_snow_user = google_api_client.user.get({'id': 7})

create_jon_snow_castle = google_api_client.user.castle.create({
    'id': 7,
    'castle': 'Winterfell',
})

How it works

  • you need to create configuration file named as .acg.yml.
pypi:
  username: dmytrostriletskyi
  password: d843rnd3

acg:
  name: google_api
  version: 0.1.5

  api: https://google.com/api/v1

  services:
    user:
      url: /user
      endpoints: create:post, get:get

    user.castle:
      url: /user/castle
      endpoints: create:post

Why it need PyPi credentials? acg deploy your API client to the Python Package Index to account based on credentials.

Then you will be able to install your API client with pip - pip install {name}. {name} is the first point in acg cause in configuration file (in example it is google_api).

  • if you finished configuring a file, type acg to terminal (after installation a acg package of course).
  • remember to up version in configuration file if you edit it and want to update API client.
  • you can use any HTTP-methods and put any data to it, because acg based on requests library.
  • endpoints needs to be separated by comma.
  • one endpoint's cause contains end of client sequence and http-method type (e.g. create:post).

After all of that you can import API client to code:

from google_api import google_api_client

Client module is always based on {name}_client. If you called your package as Hello, you are able import client following next code:

from Hello import Hello_client

Install

Following command in your terminal (you are able to use pip3):

pip install acg

Or install source code and follow this:

python setup.py install

More Repositories

1

threads-net

Unofficial and reverse-engineered Threads (threads.net) Python API wrapper. Created for academic purposes and is not intended to be used in real software.
Python
422
star
2

diagrams-as-code

Diagrams as code: declarative configurations using YAML for drawing cloud system architectures.
Python
303
star
3

accessify

Python design kit: interfaces, declared exception throws, class members accessibility levels (private and protected methods for humans).
Python
108
star
4

django-telegram-login

The reusable Django application for Telegram authorization (also known as Telegram login).
Python
100
star
5

8-bit-computer-memory-init

Initialize the 8-bit computer memory with a program to be executed automatically on powering.
C++
65
star
6

heroku-load-balancer

Inexpensive load balancer to replace Herokuโ€™s built-in one. The way to host CPU-bound.
Python
65
star
7

stale-feature-branch-operator

Delete stale feature branches in a Kubernetes cluster.
Go
51
star
8

DuttyBot

University timetable bot.
Python
28
star
9

pdbe

Debug the whole project, particular app or file with only one terminal command. Also pdbe provides features to work with debugging in the Git style.
Python
23
star
10

Rutetider

iOS, Android, Web-based and Telegram-bots timetable framework for universities. [not supported]
Python
23
star
11

utbone

Bones for faster unit testing based on the command line.
Python
13
star
12

github-story

Chrome and Firefox extension to use pull request description template with a single button click.
JavaScript
10
star
13

project-version

Explicit, strict and automatic project version management based on semantic versioning.
Python
5
star
14

DOU

Read dou.ua on your iPhone.
Swift
2
star