---
title: 'API Reference'
weight: 4
next: '/docs/configuration'
---
## Query API
```javascript{filename="Reference"}
//
Hey
const el = doc.find(".element")
el.text() // "Hey"
el.html() // `Hey
`
el.attr("foo") // "bar"
el.hasAttr("foo") // true
el.hasClass("element") // true
//
// - Item 1
// - Item 2
// - Item 3
//
const list = doc.find("ul")
list.children() // [Item 1, Item 2, Item 3]
const items = list.find("li")
items.length() // 3
items.first() // Item 1
items.last() // Item 3
items.get(1) // Item 2
items.get(1).prev() // Item 1
items.get(1).next() // Item 3
items.get(1).parent() //
items.get(1).siblings() // [Item 1, Item 2, Item 3]
items.map(item => item.text()) // ["Item 1", "Item 2", "Item 3"]
items.filter(item => item.hasClass("a")) // [Item 1]
```
## Document Parsing
```javascript{filename="Reference"}
import { parse } from "flyscrape";
const doc = parse(`bar
`);
const text = doc.find(".foo").text();
```
## File Downloads
```javascript{filename="Reference"}
import { download } from "flyscrape/http";
download("http://example.com/image.jpg") // downloads as "image.jpg"
download("http://example.com/image.jpg", "other.jpg") // downloads as "other.jpg"
download("http://example.com/image.jpg", "dir/") // downloads as "dir/image.jpg"
// If the server offers a filename via the Content-Disposition header and no
// destination filename is provided, Flyscrape will honor the suggested filename.
// E.g. `Content-Disposition: attachment; filename="archive.zip"`
download("http://example.com/generate_archive.php", "dir/") // downloads as "dir/archive.zip"
```