GithubHelp home page GithubHelp logo

cytomine-uliege / cytomine-js-client Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cytomine/cytomine-js-client

1.0 4.0 1.0 994 KB

Client to interact with Cytomine API in Javascript. Our fork includes R&D experimental features. See @cytomine for official releases.

License: Apache License 2.0

JavaScript 99.17% Shell 0.80% Groovy 0.03%
javascript cytomine

cytomine-js-client's Introduction

Cytomine Javascript Client

When using our software, we kindly ask you to cite our website URL and related publications in all your work (publications, studies, oral presentations,...). In particular, we recommend to cite (Marée et al., Bioinformatics 2016) paper, and to use our logo when appropriate. See our license files for additional details.

Presentation

Cytomine-js-client is an opensource javascript client allowing to communicate with the REST API of a Cytomine instance. For more information about Cytomine, go to https://www.cytomine.org. See installation instructions here : https://doc.cytomine.org/dev-guide/clients/javascript/installation

How to use the client

The javascript client can be used in one of the following ways:

  • As an NPM module for a browser application (install with npm install cytomine-client);
  • With a direct <script> include.

In any case, the client should be used in a browser environment, since it relies on cookies for authentication.

Sample code

import {Cytomine, User, ProjectCollection} from "cytomine-client"; // required only if used as an NPM module

// Initialize connection (replace CYTOMINE_URL by an appropriate value, e.g. "http://demo.cytomine.coop")
let cytomine = new Cytomine(CYTOMINE_URL);

// Login into Cytomine
await cytomine.login("username", "password"); // or await Cytomine.instance.login("username", "password");

// Fetch the connected user, and log "Hello " followed by its username in the console
let user = await User.fetchCurrent();
console.log("Hello " + user.username);

// Fetch the projects available to the current user and log their names in the console
let projects = await ProjectCollection.fetchAll();
console.log("You have access to these projects:");
for(let project of projects) {
    console.log(project.name);
}

Development

Installation

First checkout the repository, then install the dependencies with

npm install

Test execution

Prior to the first test execution, update the tests configuration file with appropriate values (beware that the tests will create data on the configured Cytomine instance!). To avoid committing the configuration values, it is advised to run git update-index --skip-worktree tests/config.js.

Then, to execute the tests, run

npm run test

Note that the execution of the tests requires Mozilla Firefox browser. Moreover, the Cytomine instance used for the tests must allow CORS.

Build for production with minification

npm run build

Generates a minified file located in dist folder, which can be included with <script>

Create a tarball

npm pack

The tarball can then be installed in another npm project with

npm install PATH_TO_TARBALL

cytomine-js-client's People

Contributors

bathienle avatar dependabot[bot] avatar geektortoise avatar paulbarza avatar urubens avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

neubias-wg5

cytomine-js-client's Issues

Add method to easily manage thumbnails

Add helpers for image instance, slice instances etc. to get thumbnail URL, macro URL or label URL. The helpers should provide the desired size, format and other options as arguments.

See existing commit to fetch in upstream.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.