Quantcast
Channel: Planet Python
Viewing all articles
Browse latest Browse all 24375

Zato Blog: New API Integration Tutorial in Python

$
0
0

New API Integration Tutorial in Python

Do you know what airports, telecom operators, defense forces and health care organizations have in common?

They all rely heavily on deep-backend software systems which are integrated and automated using principled methodologies, innovative techniques and well-defined implementation frameworks.

If you'd like to learn how to integrate and automate such complex systems correctly, head over to the new API integration tutorial that will show you how to do it in Python too.

# -*- coding: utf-8 -*-# Zatofromzato.server.serviceimportService# ##############################################################################classMyService(Service):""" Returns user details by the person's name."""name='api.my-service'# I/O definitioninput='-name'output='user_type','account_no','account_balance'defhandle(self):# For later usename=self.request.input.nameor'partner'# REST connectionscrm_conn=self.out.rest['CRM'].connbilling_conn=self.out.rest['Billing'].conn# Prepare requestscrm_request={'UserName':name}billing_params={'USER':name}# Get data from CRMcrm_data=crm_conn.get(self.cid,crm_request).data# Get data from Billingbilling_data=billing_conn.post(self.cid,params=billing_params).data# Extract the business information from both systemsuser_type=crm_data['UserType']account_no=crm_data['AccountNumber']account_balance=billing_data['ACC_BALANCE']self.logger.info(f'cid:{self.cid} Returning user details for {name}')# Now, produce the response for our callerself.response.payload={'user_type':user_type,'account_no':account_no,'account_balance':account_balance,}# ##############################################################################



API programming screenshots
➤ Here's the API integration tutorial again
➤ More API programming examples in Python


Viewing all articles
Browse latest Browse all 24375

Trending Articles