Other functions
Get Credential
- Typescript
- Python
- Java
- PHP
- Golang
import { Bloock, IdentityClient } from '@bloock/sdk';
try {
  // we set the API key and create a client
  Bloock.setApiKey(process.env['API_KEY'] || "");
  // we set de identity managed API host you have deployed
  Bloock.setIdentityApiHost(process.env['IDENTITY_MANAGED_API_HOST'] || "");
  // initialize the IdentityClient
  const identityClient = new IdentityClient();
  // we need the credential id, we must have been saved when we created
  const savedCredentialID = "fdd4bf52-bac7-4f41-a743-5b0580168eb3"
  // we can call the get credential function, and will retrieve the Credential entity
  const credentialEntity = await identityClient.getCredential(savedCredentialID)
  console.log(credentialEntity)
} catch (e) {
  console.log(e);
}
import os
import bloock
from bloock.client.identity import IdentityClient
# we set the API key and create a client
bloock.api_key = os.environ["API_KEY"]
# we set de identity managed API host you have deployed
bloock.identity_api_host = os.environ["IDENTITY_MANAGED_API_HOST"]
# initialize the IdentityClient
identity_client = IdentityClient()
# we need the credential id, we must have been saved when we created
saved_credential_id = "fdd4bf52-bac7-4f41-a743-5b0580168eb3"
# we can call the get credential function, and will retrieve the Credential entity
credential_entity = identity_client.get_credential(saved_credential_id)
print(credential_entity)
import java.io.IOException;
import java.time.LocalDate;
import java.time.LocalDateTime;
import com.bloock.sdk.Bloock;
import com.bloock.sdk.client.IdentityClient;
import com.bloock.sdk.entity.identity.Credential;
public class GetCredential {
  public static void main(String[] args) throws Exception {
    try {
      // we set the API key and create a client
      Bloock.apiKey = System.getenv("API_KEY");
      // we set de identity managed API host you have deployed
      Bloock.identityApiHost = System.getenv("IDENTITY_MANAGED_API_HOST");
      // initialize the IdentityClient
      IdentityClient identityClient = new IdentityClient();
      // we need the credential id, we must have been saved when we created
      String savedCredentialID = "fdd4bf52-bac7-4f41-a743-5b0580168eb3";
      // we can call the get credential function, and will retrieve the Credential entity
      Credential credentialEntity = identityClient.getCredential(savedCredentialID);
      System.out.println(credentialEntity);
    } catch (Exception e) {
      System.out.println(e);
    }
  }
}
<?php
use Bloock\Bloock;
use Bloock\Client\IdentityClient;
require "./vendor/autoload.php";
// we set the API key and create a client
Bloock::$apiKey = getenv("API_KEY") ?: "";
// we set de identity managed API host you have deployed
Bloock::$identityApiHost = getenv("IDENTITY_MANAGED_API_HOST") ?: "";
// initialize the IdentityClient
$identityClient = new IdentityClient();
// we need the credential id, we must have been saved when we created
$savedCredentialEntity = "fdd4bf52-bac7-4f41-a743-5b0580168eb3";
// we can call the get credential function, and will retrieve the Credential entity
$credentialEntity = $identityClient->getCredential($savedCredentialEntity);
package main
import (
	"log"
	"os"
	"time"
	"github.com/bloock/bloock-sdk-go/v2"
	"github.com/bloock/bloock-sdk-go/v2/client"
)
func main() {
	// we set the API key and create a client
	bloock.ApiKey = os.Getenv("API_KEY")
	// we set de identity managed API host you have deployed
	bloock.IdentityApiHost = os.Getenv("IDENTITY_MANAGED_API_HOST")
	// initialize the IdentityClient
	identityClient := client.NewIdentityClient()
	// we need the credential id, we must have been saved when we created
	savedCredentialID := "fdd4bf52-bac7-4f41-a743-5b0580168eb3"
	// we can call the get credential function, and will retrieve the Credential entity
	credentialEntity, err := identityClient.GetCredential(savedCredentialID)
	if err != nil {
		log.Fatalln(err)
	}
	log.Println(credentialEntity) 
}
Get Schema
- Typescript
- Python
- Java
- PHP
- Golang
import { Bloock, IdentityClient } from '@bloock/sdk';
try {
  // we set the API key and create a client
  Bloock.setApiKey(process.env['API_KEY'] || "");
  // we set de identity managed API host you have deployed
  Bloock.setIdentityApiHost(process.env['IDENTITY_MANAGED_API_HOST'] || "");
  // initialize the IdentityClient
  const identityClient = new IdentityClient();
  // we need the schema id, we must have been saved when we created
  const savedSchemaID = "QmadTvnNKvj2fBDgen35uAp1TfP9pSPVCNeDWw4fitqqne"
  // we can call the get schema function, and will retrieve the Schema entity
  const schemaEntity = await identityClient.getSchema(savedSchemaID)
  console.log(schemaEntity.cid) // Schema identifier generated from IPFS. Ex: QmadTvnNKvj2fBDgen35uAp1TfP9pSPVCNeDWw4fitqqne.
  console.log(schemaEntity.cidJsonLd) // Schema in JSON-LD representation. Gives you extra information about the context.
  console.log(schemaEntity.json) // represents the Schema JSON.
  console.log(schemaEntity.schemaType) // the Schema type defined above.
} catch (e) {
  console.log(e);
}
import os
import bloock
from bloock.client.identity import IdentityClient
# we set the API key and create a client
bloock.api_key = os.environ["API_KEY"]
# we set de identity managed API host you have deployed
bloock.identity_api_host = os.environ["IDENTITY_MANAGED_API_HOST"]
# initialize the IdentityClient
identity_client = IdentityClient()
# we need the schema id, we must have been saved when we created
saved_schema_id = "QmadTvnNKvj2fBDgen35uAp1TfP9pSPVCNeDWw4fitqqne"
# we can call the get schema function, and will retrieve the Schema entity
schema_entity = identity_client.get_schema(saved_schema_id)
# Schema identifier generated from IPFS. Ex: QmadTvnNKvj2fBDgen35uAp1TfP9pSPVCNeDWw4fitqqne.
print(schema_entity.cid)
# Schema in JSON-LD representation. Gives you extra information about the context.
print(schema_entity.cid_json_ld)
# represents the Schema JSON.
print(schema_entity.json)
# the Schema type defined above.
print(schema_entity.schema_type)
import java.io.IOException;
import java.time.LocalDate;
import java.time.LocalDateTime;
import com.bloock.sdk.Bloock;
import com.bloock.sdk.client.IdentityClient;
import com.bloock.sdk.entity.identity.Credential;
import com.bloock.sdk.entity.identity.Schema;
public class GetSchema {
  public static void main(String[] args) throws Exception {
    try {
      // we set the API key and create a client
      Bloock.apiKey = System.getenv("API_KEY");
      // we set de identity managed API host you have deployed
      Bloock.identityApiHost = System.getenv("IDENTITY_MANAGED_API_HOST");
      // initialize the IdentityClient
      IdentityClient identityClient = new IdentityClient();
      // we need the schema id, we must have been saved when we created
      String savedSchemaID = "QmadTvnNKvj2fBDgen35uAp1TfP9pSPVCNeDWw4fitqqne";
      // we can call the get schema function, and will retrieve the Schema entity
      Schema schemaEntity = identityClient.getSchema(savedSchemaID);
      // Schema identifier generated from IPFS. Ex:
      // QmadTvnNKvj2fBDgen35uAp1TfP9pSPVCNeDWw4fitqqne.
      System.out.println(schemaEntity.getCid());
      // Schema in JSON-LD representation. Gives you extra information about the
      // context.
      System.out.println(schemaEntity.getCidJsonLD());
      // represents the Schema JSON.
      System.out.println(schemaEntity.getJson());
      // the Schema type defined above.
      System.out.println(schemaEntity.getSchemaType());
    } catch (Exception e) {
      System.out.println(e);
    }
  }
}
<?php
use Bloock\Bloock;
use Bloock\Client\IdentityClient;
require "./vendor/autoload.php";
// we set the API key and create a client
Bloock::$apiKey = getenv("API_KEY") ?: "";
// we set de identity managed API host you have deployed
Bloock::$identityApiHost = getenv("IDENTITY_MANAGED_API_HOST") ?: "";
// initialize the IdentityClient
$identityClient = new IdentityClient();
// we need the schema id, we must have been saved when we created
$savedSchemaID = "QmadTvnNKvj2fBDgen35uAp1TfP9pSPVCNeDWw4fitqqne";
// we can call the get schema function, and will retrieve the Schema entity
$schemaEntity = $identityClient->getSchema($savedSchemaID);
$schemaEntityCID = $schemaEntity->getCid(); // Schema identifier generated from IPFS. Ex: QmadTvnNKvj2fBDgen35uAp1TfP9pSPVCNeDWw4fitqqne.
$schemaEntityJsonLD = $schemaEntity->getCidJsonLd(); // Schema in JSON-LD representation. Gives you extra information about the context.
$schemaEntityJson = $schemaEntity->getJson(); // represents the Schema JSON.
$schemaEntityType = $schemaEntity->getSchemaType(); // the Schema type defined above.
package main
import (
	"log"
	"os"
	"github.com/bloock/bloock-sdk-go/v2"
	"github.com/bloock/bloock-sdk-go/v2/client"
)
func main() {
	// we set the API key and create a client
	bloock.ApiKey = os.Getenv("API_KEY")
	// we set de identity managed API host you have deployed
	bloock.IdentityApiHost = os.Getenv("IDENTITY_MANAGED_API_HOST")
	// initialize the IdentityClient
	identityClient := client.NewIdentityClient()
	// we need the schema id, we must have been saved when we created
	savedSchemaID := "QmadTvnNKvj2fBDgen35uAp1TfP9pSPVCNeDWw4fitqqne"
	// we can call the get schema function, and will retrieve the Schema entity
	schemaEntity, err := identityClient.GetSchema(savedSchemaID)
	if err != nil {
		log.Fatalln(err)
	}
	log.Println(schemaEntity.Cid)        // schema identifier generated from IPFS. Ex: QmadTvnNKvj2fBDgen35uAp1TfP9pSPVCNeDWw4fitqqne.
	log.Println(schemaEntity.CidJsonLd)  // schema in JSON-LD representation. Gives you extra information about the context.
	log.Println(schemaEntity.Json)       // represents the schema JSON.
	log.Println(schemaEntity.SchemaType) // the schema type defined above.
}
Credential to JSON / JSON to Credential
- Typescript
- Python
- Java
- PHP
- Golang
import { Bloock, IdentityClient, Credential } from '@bloock/sdk';
try {
  // we set the API key and create a client
  Bloock.setApiKey(process.env['API_KEY'] || "");
  // we set de identity managed API host you have deployed
  Bloock.setIdentityApiHost(process.env['IDENTITY_MANAGED_API_HOST'] || "");
  // initialize the IdentityClient
  const identityClient = new IdentityClient();
  // we need the credential id, we must have been saved when we created
  const savedCredentialID = "fdd4bf52-bac7-4f41-a743-5b0580168eb3"
  // we can call the get credential function, and will retrieve the Credential entity
  const credentialEntity = await identityClient.getCredential(savedCredentialID)
  // now we can convert the Credential entity to an string JSON
  const credentialRawJson = await credentialEntity.toJson()
  console.log(credentialRawJson)
  // and we can do the opposite step, convert a JSON credential into a Credential entity
  const credEntity = await Credential.fromJson(credentialRawJson)
  console.log(credEntity)
} catch (e) {
  console.log(e);
}
import os
import bloock
from bloock.client.identity import IdentityClient
# from bloock.entity.identity.credential import Credential
# we set the API key and create a client
bloock.api_key = os.environ["API_KEY"]
# we set de identity managed API host you have deployed
bloock.identity_api_host = os.environ["IDENTITY_MANAGED_API_HOST"]
# initialize the IdentityClient
identity_client = IdentityClient()
# we need the credential id, we must have been saved when we created
saved_credential_id = "fdd4bf52-bac7-4f41-a743-5b0580168eb3"
# we can call the get credential function, and will retrieve the Credential entity
credential_entity = identity_client.get_credential(saved_credential_id)
# now we can convert the Credential entity to an string JSON
credential_raw_json = credential_entity.to_json()
print(credential_raw_json)
# and we can do the opposite step, convert a JSON credential into a Credential entity
# credential_entity = Credential.from_json(credential_raw_json)
print(credential_entity)
import java.io.IOException;
import java.time.LocalDate;
import java.time.LocalDateTime;
import com.bloock.sdk.Bloock;
import com.bloock.sdk.client.IdentityClient;
import com.bloock.sdk.entity.identity.Credential;
public class CredentialJson {
  public static void main(String[] args) throws Exception {
    try {
      // we set the API key and create a client
      Bloock.apiKey = System.getenv("API_KEY");
      // we set de identity managed API host you have deployed
      Bloock.identityApiHost = System.getenv("IDENTITY_MANAGED_API_HOST");
      // initialize the IdentityClient
      IdentityClient identityClient = new IdentityClient();
      // we need the credential id, we must have been saved when we created
      String savedCredentialID = "fdd4bf52-bac7-4f41-a743-5b0580168eb3";
      // we can call the get credential function, and will retrieve the Credential entity
      Credential credentialEntity = identityClient.getCredential(savedCredentialID);
      // now we can convert the Credential entity to an string JSON
      String credentialRawJson = credentialEntity.toJson();
      
      // and we can do the opposite step, convert a JSON credential into a Credential entity
      Credential credEntity = Credential.fromJson(credentialRawJson);
      System.out.println(credEntity);
    } catch (Exception e) {
      System.out.println(e);
    }
  }
}
<?php
use Bloock\Bloock;
use Bloock\Client\IdentityClient;
use Bloock\Entity\Identity\Credential;
require "./vendor/autoload.php";
// we set the API key and create a client
Bloock::$apiKey = getenv("API_KEY") ?: "";
// we set de identity managed API host you have deployed
Bloock::$identityApiHost = getenv("IDENTITY_MANAGED_API_HOST") ?: "";
// initialize the IdentityClient
$identityClient = new IdentityClient();
// we need the credential id, we must have been saved when we created
$savedCredentialEntity = "fdd4bf52-bac7-4f41-a743-5b0580168eb3";
// we can call the get credential function, and will retrieve the Credential entity
$credentialEntity = $identityClient->getCredential($savedCredentialEntity);
// now we can convert the Credential entity to an string JSON
$credentialRawJson = $credentialEntity->toJson();
// and we can do the opposite step, convert a JSON credential into a Credential entity
$credentialEntity = Credential::fromJson($credentialRawJson);
package main
import (
	"log"
	"os"
	"github.com/bloock/bloock-sdk-go/v2"
	"github.com/bloock/bloock-sdk-go/v2/client"
	"github.com/bloock/bloock-sdk-go/v2/entity/identity"
)
func main() {
	// we set the API key and create a client
	bloock.ApiKey = os.Getenv("API_KEY")
	// we set de identity managed API host you have deployed
	bloock.IdentityApiHost = os.Getenv("IDENTITY_MANAGED_API_HOST")
	// initialize the IdentityClient
	identityClient := client.NewIdentityClient()
	// we need the credential id, we must have been saved when we created
	savedCredentialID := "fdd4bf52-bac7-4f41-a743-5b0580168eb3"
	// we can call the get credential function, and will retrieve the Credential entity
	credentialEntity, err := identityClient.GetCredential(savedCredentialID)
	if err != nil {
		log.Fatalln(err)
	}
	// now we can convert the Credential entity to an string JSON
	credentialRawJSON, err := credentialEntity.ToJson()
	if err != nil {
		log.Fatalln(err)
	}
	log.Println(credentialRawJSON)
	// and we can do the opposite step, convert a JSON credential into a Credential entity
	credentialEntity, err = identity.NewCredentialFromJson(credentialRawJSON)
	if err != nil {
		log.Fatalln(err)
	}
	log.Println(credentialEntity)
}