Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
4 views

Object – Oriented Programming in Python-1

Oop

Uploaded by

rukkuddha1818
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Object – Oriented Programming in Python-1

Oop

Uploaded by

rukkuddha1818
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Working with : API

• What is API ?
• What is Web API?
• Advantages of using a Web API.
• Requests Library(requests library).
• Git and GitHub Repositories.
What is API?
• API – (Application Programming interface)
• API is a set of protocols , routines, and tools for building software and applications.
• It specifies how software components should interact and API’s allow
communication b/w different systems or platforms.
• API acts as an intermediary between two systems.

What is Web API?


• It’s a type of API that is hosted on the web and accessed over the internet using
standard web protocols such as HTTP
• A Web API is used to allow communication b/w a web application and a server.
• It is designed to provide an interface for web applications to interact with a server,
to making it possible for web application to access resources and data from a server
and vice versa.
• EX: Private weather applications, they can use a weather API to access and retrieve
weather data from a source such as a government weather agency.
Advantages of Web API:
• Easy Access
• Flexibility
• Cost-Effective
• Scalability
• Interoperability
• Reusability

API Key:
• API Key acts as a secret code that identifies the calling program and grants access
to the API’s data and functionality.
• The use of API key helps to ensure that the API is used only by authorized clients
and helps to maintain the security and integrity of the data and services provided
by the API.
Requests Library(requests):
• It is a python library used to send http requests.
• It is designed to provide a simple and intuitive interface for making http requests.
• The basic use of requests involves sending an http requests to specified URL , and
processing the response that is received from the server.
• This process can be done by using requests. get method for making GET requests,
or the requests.post method for making POST requests.
• commands to install requests library pip install requests.
• Ex: https://api.genderize.io offers an API that determines the gender, to utilize the
API, the name is passed as a parameter in the url.
URL : https://api.genderize.io/?name=Chandhana
URL : https://api.apilayer.com/fixer/convert?
to={to_currency}&from={from_currency}&amount={amount}&apikey={api_ke
y}
• The API then returns the results in JSON format, including information such as the
name, gender and a probability score.
• An example of the API’s response, When the name “Chandhana ” is passed.
• Response : {"count":26,"name":"chandhana","gender":"female","probability":0.54}
This program uses web API to find the gender based on name.

import requests

str = input(“Enter your name(I will tell your gender):”)


url = “ https://api.genderize.io/?name =”+str
response = requests. get(url)

if response .status_code = = 200: Output:


data = response.json() Enter your name(I will tell your gender):
Chandhana
print(“Name:”, data[‘name’]) Name: Chandhana
print(“Gender:”, data[‘gender’]) Gender: female
else:
print(“Failed to retrieve data”)
Git and GitHub Repositories:
• It is a version control systems and hosting platforms for software
development, They store and manage large amounts of codes,
documentation, and other files related to software projects.
• Git : It helps manage and keep track of changes made to a project’s
codebase.
• It allows developers to store different versions of the codebase and revert
back to an earlier version if needed.
• Git also enables multiple developers to collaborate on the same codebase,
making it easier to merge their changes without conflicts.
• GitHub: It is a web-based platform that hosts Git repositories.
• It is used to manage and store Git repositories and provides additional
features like bug tracking, project management, and collaboration tools.
• Developers can use GitHub to contribute to open-source projects, share
their own projects with others, and use Git to keep track of changes to the
code.
• GitHub also provides a GUI to interact with the Git repositories and visualizes the
activity and changes in a project’s codebase.
• The repositories in Git and GitHub contain real-world data, including source code,
multimedia files, and other related resources, which are managed and maintained
by a global community of developers and open-source enthusiasts.
• Both are essential tools for developers, offerings a vast and constantly growing
collections of real-world data for those looking to expand their knowledge and
advance their careers.
Object – Oriented Programming
in Python
• Introduction
• Features of OOP
• Classes and Objects
• Constructor Methods
• Attributes and Variables
• Encapsulation
• Abstraction
• Inheritance
• Polymorphism

You might also like