{"id":15178713,"url":"https://github.com/grafana/k6-jslib-httpx","last_synced_at":"2025-09-12T07:40:44.827Z","repository":{"id":42225889,"uuid":"347182913","full_name":"grafana/k6-jslib-httpx","owner":"grafana","description":"httpx k6 library","archived":false,"fork":false,"pushed_at":"2025-06-04T12:07:55.000Z","size":25,"stargazers_count":13,"open_issues_count":6,"forks_count":6,"subscribers_count":143,"default_branch":"master","last_synced_at":"2025-09-07T01:34:09.227Z","etag":null,"topics":["http","jslib","k6"],"latest_commit_sha":null,"homepage":"https://grafana.com/docs/k6/latest/javascript-api/jslib/httpx/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/grafana.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-12T19:58:09.000Z","updated_at":"2025-06-12T12:45:14.000Z","dependencies_parsed_at":"2022-08-20T20:00:57.566Z","dependency_job_id":"9cb1683f-2765-41f9-978e-11e8343cfc03","html_url":"https://github.com/grafana/k6-jslib-httpx","commit_stats":{"total_commits":11,"total_committers":8,"mean_commits":1.375,"dds":0.7272727272727273,"last_synced_commit":"07ba99b18604b7eb5485d0896c09788ff990f1b6"},"previous_names":["k6io/k6-jslib-httpx"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/grafana/k6-jslib-httpx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grafana%2Fk6-jslib-httpx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grafana%2Fk6-jslib-httpx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grafana%2Fk6-jslib-httpx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grafana%2Fk6-jslib-httpx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grafana","download_url":"https://codeload.github.com/grafana/k6-jslib-httpx/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grafana%2Fk6-jslib-httpx/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274777536,"owners_count":25347647,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-12T02:00:09.324Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["http","jslib","k6"],"created_at":"2024-09-27T15:22:04.090Z","updated_at":"2025-09-12T07:40:44.788Z","avatar_url":"https://github.com/grafana.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# k6-jslib-httpx\nhttpx JavaScript library \n\nDocs: https://grafana.com/docs/k6/latest/javascript-api/jslib/httpx\n\nDownload the latest release from https://jslib.k6.io/\n\n\n## Example\n\n```javascript\nimport { test } from 'https://jslib.k6.io/functional/0.0.1/index.js';\nimport { Httpx } from 'https://jslib.k6.io/httpx/0.0.6/index.js';\nimport { randomIntBetween, \n         randomItem } from \"https://jslib.k6.io/k6-utils/1.2.0/index.js\";\n\nconst USERNAME = `user${randomIntBetween(1, 100000)}@example.com`;  // random email address\nconst PASSWORD = 'superCroc2021';\n\nlet session = new Httpx({\n    baseURL: 'https://test-api.k6.io', \n    headers: {\n        'User-Agent': \"My custom user agent\",\n        \"Content-Type\": 'application/x-www-form-urlencoded' \n    },\n    timeout: 20000 // 20s timeout.\n});\n\nexport default function testSuite() {\n\n  test(`Create a test user ${USERNAME}`, (t) =\u003e {\n\n    let resp = session.post(`/user/register/`, {\n      first_name: 'Crocodile',\n      last_name: 'Owner',\n      username: USERNAME,\n      password: PASSWORD,\n    });\n\n    t.expect(resp.status).as(\"status\").toEqual(201)\n      .and(resp).toHaveValidJson();\n  })\n\n  \u0026\u0026\n\n  test(`Authenticate the new user ${USERNAME}`, (t) =\u003e {\n\n    let resp = session.post(`/auth/token/login/`, {\n      username: USERNAME,\n      password: PASSWORD\n    });\n\n    t.expect(resp.status).as(\"Auth status\").toBeBetween(200, 204)\n      .and(resp).toHaveValidJson()\n      .and(resp.json('access')).as(\"auth token\").toBeTruthy();\n\n    let authToken = resp.json('access');\n    // set the authorization header on the session for the subsequent requests.\n    session.addHeader('Authorization', `Bearer ${authToken}`);\n\n  })\n\n  \u0026\u0026\n\n  test('Create a new crocodile', (t) =\u003e {\n    let payload = {\n      name: `Croc Name`,\n      sex: randomItem([\"M\", \"F\"]),\n      date_of_birth: '2019-01-01',\n    };\n\n    let resp = session.post(`/my/crocodiles/`, payload);\n\n    t.expect(resp.status).as(\"Croc creation status\").toEqual(201)\n      .and(resp).toHaveValidJson();\n  })\n\n}\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrafana%2Fk6-jslib-httpx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrafana%2Fk6-jslib-httpx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrafana%2Fk6-jslib-httpx/lists"}