title: Understanding HTTP requests --- authenticating with rapidgator--- how does it work?
body: <p>I am confused about http requests and how it works when requesting links.</p>
  
  <p>So I know a GET requests adds parameters to urls like ?username=ABC123&amp;password=TTT and POST just sends data to the server but thats <strong>all</strong> I get when reading tutorials out there. How would I for example send a request and download a file from a rapidgator link after authenticating? (I am a premium user).</p>
  
  <p>Link to their api doc:
  <a href="https://support.rapidgator.net/index.php?/Knowledgebase/Article/View/89/9/do-you-have-api" rel="nofollow noreferrer">https://support.rapidgator.net/index.php?/Knowledgebase/Article/View/89/9/do-you-have-api</a></p>
  
  <p>The first response gives back a response object like this which gives the session id which is where I got the session id from:</p>
  
  <pre><code>{
    "response": {
      "expire_date":1351526400,
      "traffic_left":0,
      "reset_in":11695
    },
    "response_status":200,
    "response_details":null
  }
  </code></pre>
  
  <p>This is my code:</p>
  
  <pre><code>const rp = require('request-promise');
  const url = 'http://rapidgator.net/api/user/login';
  const opts = {
    uri: url,
    qs: {
      username: '**censored**',
      password: '**censored**',
    },
    headers: {
      'User-Agent': 'Request-Promise'
  },
    json: true
  }
  
  rp(opts)
  .then(( resp ) =&gt; {
    const sessionId = resp.session_id;
    const postOpts = {
      uri: 'http://rapidgator.net/api/user/info?sid=knf3pqpg3ldm05qnol0sn16326',
      method: 'POST',
      body: {
        session_id: sessionId
      },
      json: true
    }
    rp(postOpts)
    .then(res =&gt; {
      console.log(cyan(JSON.stringify(res, null, 2)));
    })
  })
  .catch(( err ) =&gt; {
    throw Error(err);
  });
  </code></pre>
  
  <p>Am I approaching this the wrong way? How do I proceed to download links from rapidgator? </p>