VOOZH about

URL: https://www.geeksforgeeks.org/javascript/d3-js-d3-fetch-api/

⇱ D3.js d3-Fetch API - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

D3.js d3-Fetch API

Last Updated : 15 Jul, 2025

D3.js is a library built with javascript and particularly used for data visualization. But this is not only, we can also fetch files of different formats such as xml, csv, pdf etc. using d3-Fetch API.

Importing the d3-Fetch API:

<script src = "https://d3js.org/d3.v4.min.js"></script>
<script src="https://d3js.org/d3-fetch.v1.min.js"></script>

Syntax: 

d3.csv(filelocation).then(function);

Types of file it can fetch:

  • Blob
  • Buffer
  • CSV
  • DSV
  • Text
  • HTML
  • XML

NOTE:  It is essential to create the file before fetching the file. Otherwise it throw error.


Example 1: 

Output: 
 

👁 Image


Example 2:

Output: 
 

👁 Image
Comment
Article Tags: