Skip to main content

Cocoyoyo_Librairie_Python_Api

Official Cocoyoyolibrairie Python Api

Search, add, remove, modify books and find users in the cocoyoyolibrairie with this package !

Getting Started:

Install:

pip3 install cocoyoyo-librairie-api

Upgrade:

pip3 install cocoyoyo-librairie-api --upgrade

Starting code:

from pprint import pprint
from cocoyoyo_librairie_api.api import CocoyoyoLibrairie, CocoyoyoLibrairie_Exception, Decorators

""" If you want to disable the message on init: """
# module = CocoyoyoLibrairie(False)
""" else: """
module = CocoyoyoLibrairie()

# search a book
search = module.search('Petit')
""" Uncomment below to view result """
# pprint(search)

# search a book by his id
search_id = module.search_id(search['resultat_livres'][0]['id'])
""" Uncomment below to view result """
# pprint(search_id)

# search a book by his isbn (WARNING !!! ALL BOOKS FIND WITH THIS METHOD AREN'T NECESSARILY IN THE COCOYOYOLIBRAIRIE)
search_isbn = module.search_isbn(9791035204396)
""" Uncomment below to view result """
# pprint(search_isbn)

# search an user
search_user = module.search_user('No Token')
""" Uncomment below to view result """
# pprint(search_user)

# get book link by his id
book_link = module.get_book_link('book_id')
""" Uncomment below to view result """
# print(book_link)

# get book by his link
get_book_by_his_link = module.get_book_by_link('https://cocoyoyo-librairie.camponovo.space/book/6082d0cb6da28284066a9549')
""" Uncomment below to view result """
# print(get_book_by_his_link)

"""
I want to have doc of library
Uncomment below to view result
"""
# print(module.__doc__)

"""
I want to have doc of search() method
Uncomment below to view result
"""
# print(module.search.__doc__)


""" You can catch exceptions of API: """
try:
    search_user = module.search_user('00')
except CocoyoyoLibrairie_Exception as e:
    """
    instructions after catching error
    """
    # print(f'An exception occurred !\n{e.__class__.__name__}: {"".join(e.args)} !')

Advanced functions (need to have an account):

from pprint import pprint
from cocoyoyo_librairie_api.api import CocoyoyoLibrairie, CocoyoyoLibrairie_Exception

module = CocoyoyoLibrairie()

# advanced api functions | these functions needed to be connect:

# setup account
get_account = module.setup('your user_name',
                           'your token',
                           'your api_key')
# all of these informations are here : https://cocoyoyo-librairie.camponovo.space/infos
print(get_account)

# add a book
# IMPORTANT ! ALWAYS PUT VALUE AND KEYS IN DOUBLE QUOTES
add_book = module.add_book({"titre": "titre", "auteur": "auteur", "date": "date", "resume": "resume", "pages": "pages", "tags": "tags"})
print(add_book)

# modify a book
# IMPORTANT ! ALWAYS PUT VALUE AND KEYS IN DOUBLE QUOTES
modify_book = module.modify_book('book_id', {"titre": "modifications", "auteur": "modifications", "date": "modifications", "resume": "modifications", "pages": "modifications", "tags": "modifications"})
print(modify_book)

# delete a book
# IMPORTANT ! ALWAYS PUT VALUE AND KEYS IN DOUBLE QUOTES
delete_book = module.delete_book('book_id')
print(delete_book)

Décorateurs:

from cocoyoyo_librairie_api.api import Decorators
""" You can use all functions above with a decorator like this: """
# IMPORTANT ! THESE FUNCTION NEED TO HAVE EXACTLY THE SAME ARGUMENTS THAN THE EXAMPLES

cocoyoyoLibrairie = Decorators(False)


@cocoyoyoLibrairie.search_user
def search_user(token, user_infos: dict):
    """ Uncomment below to view result """
    # print(f"Searching user with token {token}")
    # print(f'I found this user:\n')
    # pprint(user_infos)


""" Uncomment below to view result """
# put a valid user token token here
# search_user('token')


@cocoyoyoLibrairie.search_isbn
def search_isbn(isbn, book_infos: dict):
    """ Uncomment below to view result """
    # print(f"Searching book with isbn {isbn}")
    # print(f'I found this book:\n')
    # pprint(book_infos)


""" Uncomment below to view result """
# search_isbn(9791035204396)


@cocoyoyoLibrairie.search_id
def search_id(_id, book_infos: dict):
    """ Uncomment below to view result """
    # print(f"Searching book with isbn {_id}")
    # print(f'I found this book:\n')
    # pprint(book_infos)


""" Uncomment below to view result """
# search_id('6082d0cb6da28284066a9549')


@cocoyoyoLibrairie.search
def search(something, only_title, book_infos: dict):
    """ Uncomment below to view result """
    # print(f"Searching book {something} with parameter only_title on {only_title}")
    # print(f'I found this book:\n')
    # pprint(book_infos)


""" Uncomment below to view result """
# IMPORTANT ! ALWAYS PUT :param book_infos AT {} AND :param only_title AT False OR True
# search('Petit', False, {})


@cocoyoyoLibrairie.get_book_link
def get_book_link(_id, link):
    """ Uncomment below to view result """
    # print(f"Getting link of book_id {_id}")
    # print(f'I found this url:\n{link}')


""" Uncomment below to view result """
# get_book_link('book_id')


@cocoyoyoLibrairie.get_book_by_link
def get_book_by_link(link, infos):
    """ Uncomment below to view result """
    # print(f"Getting book {link}")
    # print(f'I found this book:\n')
    # pprint(infos)


""" Uncomment below to view result """
# get_book_by_link('https://cocoyoyo-librairie.camponovo.space/book/6082d0cb6da28284066a9549')

Links / Developer / Contribute:

CocoyoyoLibrairie Official API made with ❤️ by CAMARM-DEV for CAMARM-DEV, inc

###- Repository ###- Contributors ###- Pypi ###- CAMARM-DEV Website ###- Gitlab Profile ###- Pypi Profile ###- Discord ###- Version History

Copyright 2021 CAMARM-DEV, inc

Metadata

Release files for cocoyoyo-librairie-api 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cocoyoyo-librairie-api 2.0.0
File Size Uploaded
cocoyoyo_librairie_api-2.0.0.tar.gz 7.3 kB Details

Release files / cocoyoyo_librairie_api-2.0.0.tar.gz

Download URL cocoyoyo_librairie_api-2.0.0.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
933618943239503a605925df97161661aa36abf27d4c3e2213d5eb8af2db49c1
BLAKE2b-256 checksum
How to use checksums
46a8fbf0153312eac531eaa637c6769caf7bb74f661b8249b735ca79b43cab0b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.7.0 requests/2.25.1 setuptools/44.1.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/2.7.17

Release history Release notifications | RSS feed

This release

2.0.0 This release

1 release file

1.5.8

1 release file

1.5.7

1 release file

1.5.6

1 release file

1.5.5

1 release file

1.5.0

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

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