Device Type

If your use case requires you to exclusively use either desktop or mobile user agents in the headers it sends to the website then you can use the device_type parameter.

  • Set device_type=desktop to have the API set a desktop (e.g. iOS, Windows, or Linux) user agent. Note: This is the default behavior. Not setting the parameter will have the same effect.

  • Set device_type=mobile to have the API set a mobile (e.g. iPhone or Android) user agent.

Note: The device type you set will be overridden if you use keep_headers=true and send your own user agent in the requests header.

  • API REQUEST

import fetch from 'node-fetch';

fetch('http://api.scraperapi.com/?api_key=APIKEY&url=http://httpbin.org/ip&device_type=mobile')
.then(response => {
console.log(response)
})
.catch(error => {
console.log(error)
})
  • PROXY MODE

const axios = require('axios');

axios.get('http://httpbin.org/ip', {
  method: 'GET',
  proxy: {
    host: 'proxy-server.scraperapi.com',
    port: 8001,
    auth: {
      user: 'scraperapi.device_type=mobile',
      password: 'APIKEY'  
    },
    protocol: 'http'
  }
})
  .then(response => {
    console.log(response)
  })
  .catch(error => {
    console.log(error)
  });
  • SDK Method

// remember to install the library: npm install scraperapi-sdk --save
const scraperapiClient = require('scraperapi-sdk')('APIKEY')

scraperapiClient.get('http://httpbin.org/ip', {device_type: 'mobile'})
.then(response => {
  console.log(response)
})
.catch(error => {
  console.log(error)
})

Last updated