Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Data Science for Web3

You're reading from  Data Science for Web3

Product type Book
Published in Dec 2023
Publisher Packt
ISBN-13 9781837637546
Pages 344 pages
Edition 1st Edition
Languages
Author (1):
Gabriela Castillo Areco Gabriela Castillo Areco
Profile icon Gabriela Castillo Areco

Table of Contents (23) Chapters

Preface Part 1 Web3 Data Analysis Basics
Chapter 1: Where Data and Web3 Meet Chapter 2: Working with On-Chain Data Chapter 3: Working with Off-Chain Data Chapter 4: Exploring the Digital Uniqueness of NFTs – Games, Art, and Identity Chapter 5: Exploring Analytics on DeFi Part 2 Web3 Machine Learning Cases
Chapter 6: Preparing and Exploring Our Data Chapter 7: A Primer on Machine Learning and Deep Learning Chapter 8: Sentiment Analysis – NLP and Crypto News Chapter 9: Generative Art for NFTs Chapter 10: A Primer on Security and Fraud Detection Chapter 11: Price Prediction with Time Series Chapter 12: Marketing Discovery with Graphs Part 3 Appendix
Chapter 13: Building Experience with Crypto Data – BUIDL Chapter 14: Interviews with Web3 Data Leaders Index Other Books You May Enjoy Appendix 1
Appendix 2
Appendix 3

A brief overview of APIs

APIs, or application programming interfaces, facilitate communication between two software services through a series of requests and responses. For instance, when we receive a notification about a token’s price drop in our telephone app, it means that our app is communicating with a price provider such as CoinMarketCap via an API. To structure a request for the desired response, we must always refer to the relevant API documentation.

For a more comprehensive understanding of APIs, we can find additional information in the book Python API Development Fundamentals by Packt Publishing . Since we will frequently interact with APIs to extract information, it’s beneficial to review the primary characteristics of different APIs. This will greatly assist us when we aim to programmatically access information.

For this purpose, we will focus on the following:

  • Remote Procedure Call (RPC) APIs: In RPC APIs, the client initiates a function on the server, and the server sends back the output. In practice, we include the method (endpoints) of the function in the URL and the arguments in the query string. In this case, the client needs to possess all the information about the endpoints, and sometimes it involves constructing a workflow with information queried from other URLs. An example of an RPC API encoded in JSON format is the Infura suite, which we have utilized in previous sections.
  • Representational State Transfer (REST) API: This API is stateless, meaning that it does not save the client’s data between requests. This is one of the most popular methods on the market because it is lightweight and easy to maintain and scale.

    The client sends requests to the server in the form of a web URL, including methods such as GET, POST, PUT, or DELETE, and the server responds, typically in JSON format. A REST request typically comprises the HTTP method, endpoint, headers, and body. The endpoint identifies the resource online, headers provide server information, such as authentication, and the body contains the information the sender wishes to transmit to the server as a request.

An alternative approach was developed by Facebook as an open source query language named GraphQL. The key difference from the aforementioned APIs is that GraphQL is a query language, whereas REST is an architectural concept for software. GraphQL is a syntax for data retrieval that empowers the client to specify the required information, unlike the REST infrastructure, where queries return fixed datasets for each endpoint (sometimes including more information than necessary).

A noteworthy feature of GraphQL is its ability to construct requests that fetch data from multiple resources using a single API call. The Graph is an indexer and query protocol for the Ethereum network that is queried using GraphQL; we will delve into it further in Chapter 2.

You have been reading a chapter from
Data Science for Web3
Published in: Dec 2023 Publisher: Packt ISBN-13: 9781837637546
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}