Summary

cURL, which stands for client URL, is a command line tool that developers use to transfer data to and from a server. At the most fundamental, cURL lets you talk to a server by specifying the location (in the form of a URL) and the data you want to send.

Can be considered as non-interactive web browser of terminal/shell.

Useful commands

Authorization

sending headers and authorizations to get response

curl https://testlogin.kfupm.edu.sa/oauth2/userinfo \
 -H "Accept: application/json" \
 -H "Authorization: Bearer 616af0af-db00-355f-bd77-8be597aec24c"

Tadafuq API

Auth

Register

curl -X 'POST' \
  'http://localhost:3001/api/v1/auth/register' \
  -H 'accept: */*' \
  -H 'Content-Type: application/json' \
  -d '
  "channelName": "test channel-1",
  "email": "test1@test.com",
  "password": "p@ssw0rd"
'

login

  • User

    curl -X 'POST' \
      'http://localhost:3001/api/v1/auth/login' \
      -H 'accept: */*' \
      -H 'Content-Type: application/json' \
      -d '
      "email": "test1@example.com",
      "password": "TTVjhd9yjREXdOVcbe4b"
    '
    
  • Admin

    curl -X 'POST' \
      'http://localhost:3001/api/v1/auth/login' \
      -H 'accept: */*' \
      -H 'Content-Type: application/json' \
      -d '
      "email": "admin@example.com",
      "password": "znhWSmsFzYOjI5gybz7u"
    '
    

Authme

curl  'http://localhost:3001/api/v1/auth/me' \
  -H 'accept: */*' \
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYyMjBhN2FiYzljZDM4N2FmYzhkZTE5ZSIsImlhdCI6MTY0OTkyNTUzMiwiZXhwIjoxNjUyNTE3NTMyfQ.lpCHBjv1CjynqlRLRWwwPJmaJhIi2NhWIsIWuy5POYk' \
  -d ''

Update Details

[ ] not working

curl -X 'PUT' 'http://localhost:3001/api/v1/auth/updatedetails' \
 -H 'accept: */*' \
  -H 'Content-Type: application/json' \
-H 'Authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYyMjBhN2FiYzljZDM4N2FmYzhkZTE5ZSIsImlhdCI6MTY0OTkyNTUzMiwiZXhwIjoxNjUyNTE3NTMyfQ.lpCHBjv1CjynqlRLRWwwPJmaJhIi2NhWIsIWuy5POYk' \
  -d '
  "channelName": "test channel-2",
  "email": "test2@test.com"
'

Avatar

[ ] not working

curl -X 'PUT' \
  'http://localhost:3001/api/v1/auth/avatar' \
  -H 'accept: */*' \
-H "Authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYyNTdkY2MwMjA3Y2I2NDhmNWIwNGZlZiIsImlhdCI6MTY0OTkyNTMxMiwiZXhwIjoxNjUyNTE3MzEyfQ.RDterh1aT9-LFgd7I8mayiUpQbVEuGwmSkTEsGLoSec"

users

Get users

curl -X 'GET' 'http://localhost:3001/api/v1/users/' \
  -H 'accept: */*' \
-H 'Authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYyNTdkY2MwMjA3Y2I2NDhmNWIwNGZlZiIsImlhdCI6MTY0OTkyNTMxMiwiZXhwIjoxNjUyNTE3MzEyfQ.RDterh1aT9-LFgd7I8mayiUpQbVEuGwmSkTEsGLoSec'