API

Application Programming Interface

---

What we saw last time

Any questions?

Today


At the end of this class

You


In the News

What caught your attention this week?

---

Claude can now edit files

https://www.anthropic.com/news/create-files

Qwen released 2 new models https://qwen.ai/blog?id=4074cca80393150c248e508aa62983f9cb7d27cd&from=research.latest-advancements-list

The name "80B-A3B" indicates 80 billion parameters of which only 3 billion are active at a time. You still need to have enough GPU-accessible RAM to hold all 80 billion in memory at once but only 3 billion will be used for each round of inference, which provides a significant speedup in responding to prompts.

More details from their tweet:

Ethan Mollick


Claude tools

In Claude:

Show me a list of tools that you have available to you, duplicating their original names and descriptions


Claude memory

https://simonwillison.net/2025/Sep/12/claude-memory/


API

An API defines

API

In other terms : an API allows apps to talk to each other.


API

  1. You send a request to a web address : a url
  2. The server answers the request
  3. You get back some data
API
# **Attention! - Attention!**

In safari and other browsers, the full URL is hidden.

In the finder, go to settings >> advanced
enable the "Show full website address" option.



Full URL in safari

What's a URL ?

A URL (Uniform Resource Locator) is the address of a unique resource on the internet.

domain name + everything else to specify the data you requested

https://{domain name}/{endpoint}?{params}

Example :

https://skatai.com//inwai/api/#slide-9

REST protocol

The REST protocol is a set of rules that define how applications can interact with each other.

Four verbs to rule the world

The whole digital economy is based on these 4 words!


Example

example on instagram, bluesky, X, facebook, tiktok, etc.

and every other website


The Web is One BIG API + GET requests
  1. on your browser you go to a url. This is the initial GET request
  2. that request triggers a call to the server.
  3. the server sends you back the content as the response, most often as JSON
Full URL in safari

The Web is an API

Let's illustrate

---

The web is one gigantic API

It uses URLs to send requests to a server

The server sends the html page back

You should end up on this URL:

https://www.goodreads.com/author/show/58.Frank_Herbert

alt text

https://www.goodreads.com/author/**show**/58.Frank_Herbert

which can be read as: show an author, with label 58.frank.herbert


/list instead of /show

Now scroll down and click on "More Books by Frank Herbert"

The URL is now https://www.goodreads.com/author/**list**/58.Frank_Herbert

The verb "/show" is replaced with the verb "/list".

Screenshot showing Books by Frank Herbert page on Goodreads


Parameters: ?page=2&per_page=30

Now click on page 2, the URL becomes

https://www.goodreads.com/author/list/58.Frank_Herbert?page=2&per_page=30

which reads


REST is the building block of the internet

An endpoint: an URL and a path

some optional parameters: ?page=2&per_page=30

A method : GET the content, PUT or POST new content, DELETE the content

The data in JSON format as the server response, or just plain text, html, pdfs, csv, audio, video etc


Examples


quizz

For each action, guess which REST verb it uses: GET, POST, PUT, or DELETE?


Hack 101

---
# DEV tools - under the hood

go on a social network or a website

  • click right and get to the developpers tools : inspect
  • click on network tab
  • like a post: you should see a request with method POST
  • click on a post: you should see a requests with method GET
inspect devtools

Exercise

Grab a screenshot of the Devtools screen, network tab

Paste in a LLM like chatGPT or Claude or ...

ask: explain in simple terms what I'm seeing

dev tools inspect


Wikipedia API

wikipedia
---

The wikipedia API

We can use the API front end (sandbox) to play with the API but as we can see it's not trivial

So we need to read :

Best to check out

#  Do a Wikipedia search for query.
wikipedia.search(query, results=10, suggestion=False)

read the docs

https://pypi.org/project/Wikipedia-API/


Install the library

First install the library : !pip install wikipedia-api

Note the ! before pip.

Then we look at some code

prompt : PIP Install the wikipedia api library


import wikipediaapi

# Initialize Wikipedia API (English)
wiki_wiki = wikipediaapi.Wikipedia( user_agent="[email protected]",  language='en')

# Get the page : the actual request to the API
page = wiki_wiki.page("Paris")

# Check if the page exists
if page.exists():
    print(f"Title: {page.title}\n")
    print(f"Summary: {page.summary[:500]}...")  # print first 500 chars of summary
else:
    print("Page not found.")

instanciate the object

pass all the parameters to specify how how want to interact with the object

wiki_wiki = wikipediaapi.Wikipedia( user_agent="[email protected]",  language='en')

wiki_wiki is the object that we use to interact with the API. It has now been initialized, or instanciated

to interrogate APIs you often also have to pass all the required identification parameters (login, password, API key, ...). This is not needed for wikipedia API. The wikipedia API is 100% open.


strings

  • Simple, direct
print("Hello world")
  • With a variable
my_var = "Hello world"
print(my_var)
  • interpolation

f-strings

my_var = "Hello world"
print(f"Greetings: {my_var}")

notice :

  • the f before the string
  • the {} around the variable

multiple variables

my_var = "Hello world"
name = "Alexis"
print(f"Greetings: {my_var} \n my name is {name}")

Notice

  • the \n .
  • \n is the line return character

Practice


Methods vs attributes

we've seen that with pandas dataframes : df.head() vs df.columns

A method / function call : notice the presence of absence of ()

page.exists()

A property on the object page: no ()

page.title

practice

Full worksheet : wikipedia api practice

short version:


Next time

new data source: aifray.com

In-depth reporting and analytical commentary on artificial intelligence regulation.


Exit ticket

exit ticket
[https://forms.gle/9eE9PUR6mFC2szq47](https://forms.gle/9eE9PUR6mFC2szq47)
1 / 0