# Get api values with javascript

**URL:** <https://forum.freecodecamp.org/t/get-api-values-with-javascript/458238>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [April 30, 2021, 1:51pm UTC](https://forum.freecodecamp.org/t/get-api-values-with-javascript/458238 "2021-04-30T13:51:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nisse](https://avatars.discourse-cdn.com/v4/letter/n/9e8a1a/32.png) [@Nisse](https://forum.freecodecamp.org/u/Nisse)\
**Post date:** [April 30, 2021, 1:51pm UTC](https://forum.freecodecamp.org/t/get-api-values-with-javascript/458238/1 "2021-04-30T13:51:52Z")

</div>

Hi!  
I try to get some values from an api.  
The api is [https://opendata-download-metfcst.smhi.se/api/category/fwif1g/version/1/daily/geotype/point/lon/15.18/lat/60.13/data.json](https://opendata-download-metfcst.smhi.se/api/category/fwif1g/version/1/daily/geotype/point/lon/15.18/lat/60.13/data.json).

I want for example the value for fwiindex to put on my homepage.  
Can I use something similar like

type or paste code here

```auto
var queryURL = "//api.luftdaten.info/v1/sensor/13481/";
$.getJSON(queryURL, function(data) {
  var result = data[0].sensordatavalues
  console.log(result);
  var value = result[0].value
  $('#output').append('The value is ' + value);
})

```

---

<div class="post-metadata">

**Author:** ![lasjorg](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/lasjorg/32/280761_2.png) [@lasjorg](https://forum.freecodecamp.org/u/lasjorg)\
**Post date:** [April 30, 2021, 2:11pm UTC](https://forum.freecodecamp.org/t/get-api-values-with-javascript/458238/2 "2021-04-30T14:11:06Z")

</div>

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (`</>`) to add backticks around text.

 ![Pre-formatted-text](https://global.discourse-cdn.com/freecodecamp/original/3X/1/b/1b18854f1059217f29370444396145cc3a0cd8ae.gif)

See [this post](https://forum.freecodecamp.org/t/forum-code-formatting/25574) to find the backtick on your keyboard.  
**Note:** Backticks (`) are not single quotes (’).

---

<div class="post-metadata">

**Author:** ![lasjorg](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/lasjorg/32/280761_2.png) [@lasjorg](https://forum.freecodecamp.org/u/lasjorg)\
**Post date:** [April 30, 2021, 2:19pm UTC](https://forum.freecodecamp.org/t/get-api-values-with-javascript/458238/3 "2021-04-30T14:19:10Z")

</div>

If you use the URL it redirects to instead it should work with the code you have.

`https://data.sensor.community/airrohr/v1/sensor/13481/`

---

<div class="post-metadata">

**Author:** ![Nisse](https://avatars.discourse-cdn.com/v4/letter/n/9e8a1a/32.png) [@Nisse](https://forum.freecodecamp.org/u/Nisse)\
**Post date:** [April 30, 2021, 4:18pm UTC](https://forum.freecodecamp.org/t/get-api-values-with-javascript/458238/4 "2021-04-30T16:18:36Z")

</div>

Yes, but I want to have the fwiindex from the api [https://opendata-download-metfcst.smhi.se/api/category/fwif1g/version/1/daily/geotype/point/lon/15.18/lat/60.13/data.json](https://opendata-download-metfcst.smhi.se/api/category/fwif1g/version/1/daily/geotype/point/lon/15.18/lat/60.13/data.json)

The other code was just an example. I am not really sure how to code to get the value.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/freecodecamp/original/3X/e/1/e1c433102e34b46dfaa3e15d13ab9a514b127078.svg) [@system](https://forum.freecodecamp.org/u/system)\
**Post date:** [October 30, 2021, 4:19am UTC](https://forum.freecodecamp.org/t/get-api-values-with-javascript/458238/5 "2021-10-30T04:19:01Z")

</div>

Closed on October 30, 2021, 4:19am UTC

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.
