Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Mwenda Harun Mbaabu
Mwenda Harun Mbaabu

Posted on

     

Introduction to the Beyonic API and Fast API

Today we will discuss how to build a payment application with Beyonic API and Fast API, which is a modern and very fast Python framework.

Beyonic API

As i had earlier written in my previous article onBuilding A Payment Application using Python Flask Framework, Docker and the Beyonic API, the Beyonic API is a REST based application programming interface that lets you extend the Beyonic dashboard features into your application and systems, allowing you to build amazing payment experiences.

Getting Help

For usage, general questions, and discussions about the Beyonic API the best place to go to isBeyhive Slack Community, also feel free to clone and edit this repository to meet your project, application or system requirements.

To start using the Beyonic Python API, you need to start by downloading the Beyonic API official Python client library and setting your secret key.

Fast API

FastAPI is a Python web framework that has been built from the ground up to make use of modern Python features. It uses the ASGI standard for asynchronous, concurrent connectivity with clients, and it can work with WSGI if needed. Async functions can be used for routes and endpoints. And FastAPI allows web applications to be written efficiently in clean, modern Python code with type hints.

As the name implies, a primary use case of FastAPI is building API endpoints. This you can accomplish as easily as returning Python dictionary data as JSON, or by using the OpenAPI standard including an interactive Swagger UI. But FastAPI is by no means limited to APIs. You can use it for just about everything else a web framework does, from delivering plain old web pages using the Jinja2 template engine to serving applications powered by WebSockets.

Set up your development environment

To learn how to securely set up a development environment visitthis repository where i have discussed to use .env file to secure your API key.

>>> pipinstallpython-dotenv>>> pipinstallbeyonic>>> pipinstallfastapi>>>  pipinstall"uvicorn[standard]"
Enter fullscreen modeExit fullscreen mode
#.env fileBEYONIC_ACCESS_KEY="enter your API"
Enter fullscreen modeExit fullscreen mode

You will get your API Token by clicking your user name on the bottom left of the left sidebar menu in the Beyonic web portal and selecting ‘Manage my account’ from the dropdown menu. The API Token is shown at the very bottom of the page.

#app.py fileimportosimportbeyonicfromfastapiimportFastAPIfromdotenvimportload_dotenvload_dotenv()app=FastAPI()myapi=os.environ['BEYONIC_ACCESS_KEY']beyonic.api_key=myapi@app.get("/contacts")defcontacts():mycontacts=beyonic.Contact.list()returnmycontacts
Enter fullscreen modeExit fullscreen mode

Running your Application:

uvicorn main:app --reload
Enter fullscreen modeExit fullscreen mode

Now open this url 👉🏻http://127.0.0.1:8000/docs on your local machine and you should see the following output in your browser.
Image description

Finally click on the contacts path then try out open and execute, if your programs runs successfully you will see the following output on your browser.

Image description

Congratulations, you have successfully listed all the contacts you have in the beyonic account, you can go on and write more complex functions which allows one to send money, receive money or request money from someone who owes using the beyonic API and .

You can check out the full MFS Africa developers documentation 👉🏻https://developers.mfsafrica.com/, to learn more about the beyonic API, or join and network with fellow developers building inspiring services with the beyonic APIs 👉🏻https://beyonic.com/join-community .

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

A Data Engineer and technical with over 5 years of experience. Let discuss your next project: mbaabuharun8@gmail.com
  • Location
    Kenya
  • Education
    Bsc( Mathematics and Computer Science)
  • Pronouns
    he/him
  • Joined

More fromMwenda Harun Mbaabu

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp