php-swh-client

Software Heritage API Client - https://doi.org/10.5281/zenodo.12808864

https://github.com/ramy-badr-ahmed/php-swh-client

Science Score: 49.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 3 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (16.1%) to scientific vocabulary

Keywords

guzzle-clients illuminate-http illuminate-validation merkle-dag php-client psysh software-archiving software-heritage software-heritage-api-client software-heritage-dag swh-api swh-archiver swh-client swh-connector swh-endpoints swh-graph swh-metadata swh-model swh-webclient swhid

Keywords from Contributors

mesh interpretability sequences generic projection interactive optim hacking network-simulation
Last synced: 4 months ago · JSON representation

Repository

Software Heritage API Client - https://doi.org/10.5281/zenodo.12808864

Basic Info
Statistics
  • Stars: 1
  • Watchers: 2
  • Forks: 2
  • Open Issues: 0
  • Releases: 2
Topics
guzzle-clients illuminate-http illuminate-validation merkle-dag php-client psysh software-archiving software-heritage software-heritage-api-client software-heritage-dag swh-api swh-archiver swh-client swh-connector swh-endpoints swh-graph swh-metadata swh-model swh-webclient swhid
Created over 1 year ago · Last pushed about 1 year ago
Metadata Files
Readme License Codemeta

README.md

GitHub top language GitHub DOI

SWH

SWH API Client

This is a PHP API client/connector for Software Heritage (SWH) web API - currently in Beta phase. The client is wrapped round the Illuminate Http package and the GuzzleHTTP library.

[!Note] Detailed documentation can be found in the wiki pages of this very repository.

A demonstrable version (some features) can be accessed here: Demo Version

Working on new features and fixes will be gladly considered. Please feel free to report.

Installation Steps:

1) Clone this project.

2) Open a console session and navigate to the cloned directory:

    Run "composer install"

    This should involve installing the PHP REPL, PsySH

3) (Optional) Acquire SWH tokens for increased SWH-API Rate-Limits.

4) Prepare .env file and add tokens:   

    4.1) Rename/Copy the cloned ".env.example" file to .env
            cp .env.example .env   

    4.2) (Optional) Edit these two token keys:

            SWH_TOKEN_PROD=Your_TOKEN_FROM_SWH_ACCOUNT              # step 3)                 
            SWH_TOKEN_STAGING=Your_STAGING_TOKEN_FROM_SWH_ACCOUNT   # step 3)                 

5) (optional) Add psysh to PATH.

Quickstart:

In a console session inside the cloned directory, start the php REPL:

```php $ psysh // if not added to PATH replace with: vendor/bin/psysh

Psy Shell v0.12.0 (PHP 8.2.0 — cli) by Justin Hileman ```

This will open a REPL console-based session where one can test the functionality of the api classes and their methods before building a suitable workflow/use-cases.

Presets

As a one-time configuration parameter, you can set the desired returned data type by SWH (default JSON):

```php

namespace Module\HTTPConnector; use Module\HTTPConnector;

HTTPClient::setOptions(responseType:'object') // json/collect/object available ```

Visits

Retrieve Latest Full Visit in the SWH archive:

```php

namespace Module\OriginVisits; use Module\OriginVisits;

$visitObject = new SwhVisits('https://github.com/torvalds/linux/');

$visitObject->getVisit('latest', requireSnapshot: true) ```

More details on further swh visits methods: SwhVisits.

DAG Model:

As graph Nodes, retrieve node Contents, Edges or find a Path to other nodes (top-bottom):

```php

namespace Module\DAGModel; use Module\DAGModel;

$snpNode = new GraphNode('swh:1:snp:bcfd516ef0e188d20056c77b8577577ac3ca6e58')

$snpNode->nodeHopp() // node contents

$snpNode->nodeEdges() // node edges keyed by the respective name

$revNode = new GraphNode('swh:1:rev:9cf5bf02b583b93aa0d149cac1aa06ee4a4f655c')

$revNode->nodeTraversal('deps/nghttp2/lib/includes/nghttp2/nghttp2ver.h.in') // traverse to a deeply nested file ```

More details on:

Archive

You can specify repositories URL w/o paths and archive to SWH using one of the two variants (static/non-static methods):

```php

namespace Module\Archival; use Module\Archival;

$saveRequest = new Archive('https://github.com/torvalds/linux/') // Example 1 $saveRequest->save2Swh()

$newSaveRequest = Archive::repository('https://github.com/hylang/hy/tree/stable/hy/core') // Example 2

// in both cases: the returned POST response contains the save request id and date

```

Enquire about archival status using the id/date of the archival request (available in the initial POST response)

```php

$saveRequest->getArchivalStatus($saveRequestDateOrID) // current status is returned $saveRequest->trackArchivalStatus($saveRequestDateOrID) // tracks until archival has succeeded ```

More details on further archive methods: Archive.

EBNF Grammar

Validate a given swhID. TypeError is thrown for non-valid swhIDs.

```php

namespace Module\DataType; use Module\DataType;

$snpID = new SwhcoreId('swh:1:snp:bcfd516ef0e188d20056c77b8577577ac3ca6e5Z') // throws TypeError Exception ```

Full details of the SWHID persistent Identifiers: Syntax

[!Note] Todo: Core identifiers with qualifiers.

MetaData

Returns a list of metadata authorities that provided metadata on the given target

```php

namespace Module\MetaData; use Module\MetaData;

SwhMetaData::getOriginMetaData('https://github.com/torvalds/linux/') ```

More details on further metadata methods: Metadata.

Owner

  • Login: Ramy-Badr-Ahmed
  • Kind: user
  • Location: Germany

CodeMeta (codemeta.json)

{
  "@context": "https://doi.org/10.5063/schema/codemeta-2.0",
  "@type": "SoftwareSourceCode",
  "datePublished": "2023-10-06",
  "dateCreated": "2023-01-31",
  "description": " Software-Heritage API-Client ",
  "name": "swh-client",
  "license": "https://spdx.org/licenses/Apache-2.0.html",
  "dateModified": "2024-05-06",
  "softwareVersion": "1.0-Beta",
  "codeRepository": "https://github.com/Ramy-Badr-Ahmed/swh-client",
  "identifier": "https://archive.softwareheritage.org/swh:1:dir:40caa1be82f300bda332b03e69aa4591e3eb2235;origin=https://github.com/Ramy-Badr-Ahmed/swh-client;visit=swh:1:snp:0940a0d4cac24a623a199e8bfa115a54dabf0b70;anchor=swh:1:rev:749a9a916ada5ddf01465773be8862489bc9328a",
  "developmentStatus": "active",
  "readme": "https://github.com/Ramy-Badr-Ahmed/swh-client/blob/main/README.md",
  "programmingLanguage": "PHP",
  "operatingSystem": "cross-platform",
  "runtimePlatform": "PHP Interpreter",
  "relatedLink": "https://1959e979-c58a-4d3c-86bb-09ec2dfcec8a.ka.bw-cloud-instance.org",
  "author": [
    {
      "@type": "Person",
      "givenName": "Ramy-Badr",
      "familyName": "Ahmed",
      "email": "126559907+Ramy-Badr-Ahmed@users.noreply.github.com"
    }
  ],
  "keywords": [
    "software-heritage",
    "swhid",
    "software-heritage-api-client",
    "swh-connector",
    "swh-client",
    "software-heritage-dag",
    "swh-metadata",
    "swh-webclient",
    "swh-graph",
    "swh-model",
    "swh-endpoints",
    "swh-api",
    "swh-archiver"
  ],
  "softwareRequirements": [
    "PHP >=8.0",
    "guzzlehttp/guzzle: >=7.2"
  ],
  "maintainer": {
    "@type": "Person",
    "givenName": "Ramy-Badr",
    "familyName": "Ahmed",
    "email": "126559907+Ramy-Badr-Ahmed@users.noreply.github.com"
  },
  "applicationCategory": [
    "API Connectors",
    "Research Software",
    "Metadata"
  ],
  "funder": {
    "@type": "Organization",
    "funding": "EU-Horizon: 101057264",
    "@id": "https://doi.org/10.3030/101057264",
    "name": "European Comission"
  }
}

GitHub Events

Total
  • Watch event: 1
  • Push event: 1
  • Pull request event: 2
  • Gollum event: 3
  • Create event: 1
Last Year
  • Watch event: 1
  • Push event: 1
  • Pull request event: 2
  • Gollum event: 3
  • Create event: 1

Committers

Last synced: 6 months ago

All Time
  • Total Commits: 15
  • Total Committers: 4
  • Avg Commits per committer: 3.75
  • Development Distribution Score (DDS): 0.333
Past Year
  • Commits: 8
  • Committers: 3
  • Avg Commits per committer: 2.667
  • Development Distribution Score (DDS): 0.25
Top Committers
Name Email Commits
Ramy-Badr-Ahmed 1****d 10
Ramy r****d@d****e 3
dependabot[bot] 4****] 1
Moritz Schubotz g****b@c****e 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 0
  • Total pull requests: 3
  • Average time to close issues: N/A
  • Average time to close pull requests: 3 days
  • Total issue authors: 0
  • Total pull request authors: 3
  • Average comments per issue: 0
  • Average comments per pull request: 0.0
  • Merged pull requests: 3
  • Bot issues: 0
  • Bot pull requests: 1
Past Year
  • Issues: 0
  • Pull requests: 3
  • Average time to close issues: N/A
  • Average time to close pull requests: 3 days
  • Issue authors: 0
  • Pull request authors: 3
  • Average comments per issue: 0
  • Average comments per pull request: 0.0
  • Merged pull requests: 3
  • Bot issues: 0
  • Bot pull requests: 1
Top Authors
Issue Authors
Pull Request Authors
  • dependabot[bot] (2)
  • Ramy-Badr-Ahmed (2)
  • physikerwelt (1)
Top Labels
Issue Labels
Pull Request Labels
dependencies (2)